|
Why are you trying to convert such values into integers? The resulting numbers are unlikely to be of any use, as they lose most of their precision. The value -0.0123456 rad looks like an angle, so converting that to an integer will give you -0 which probably is not much use.
|
|
|
|
|
The particular parameter I'm looking at right now is the value for body roll which is, as you say, measured in rads.
The value as generated by the simulator is far too low to use but simply multiplying the value before converting would give me numbers that could safely be translated to integers.
Although the output is very precise, I only need approximate values as they will be mixed in with lateral acceleration, suspension deflection and some other values so any inaccuracies will be lost in the mix so to speak.
I just want a number that I can work with!
|
|
|
|
|
For such a small starting value you need to multiply by 100 or 1000 at least, I would guess.
|
|
|
|
|
That is my intention.
I currently do the same with the Lateral acceleration values which works fine. As would this, if I could get a useful number to start from.
|
|
|
|
|
How to retrieve the data from table and put in textbox
|
|
|
|
|
We will need a lot more information than this in order to help you. Post the code you have already tried and tell us what the problem is
|
|
|
|
|
|
This solved my problem:
Dim szF As SizeF = gr.MeasureString(Me.Text.Substring(0, iIndex), Me.Font, New SizeF(999, 999), StringFormat.GenericTypographic)
I have a control derived from UserControl in which I am trying to implement like a TextBox
and I am having trouble setting the caret in the correct text column position. Below is the
code to calculate the x offset and move the caret.
Simple test:
With the text "aBc", when I try to set the caret between 'a' and 'B' (iIndex=1), the caret is displayed
almost at the end of the 'B'.
MeasureDisplayStringWidth() is test code I found on the internet and
does not make any difference than using gr.MeasureString().
SetCaretPos() is the standared Windows API for setting the caret.
And for those who wonder why I don't just use a TextBox, this control has all kinds of custom
stuff including rotation.
I would appreciate any help.
Thank you
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim sb As SolidBrush = New SolidBrush(Color.FromArgb(255, 0, 0, 255))
' Display text
e.Graphics.DrawString(Me.Text, me.Font, sb, 0, 0)
End Sub
Private Sub MoveCaret(ByVal iIndex As Integer)
Dim gr As Graphics = Me.CreateGraphics()
' Both of these give the same result.
'Dim szF As SizeF = gr.MeasureString(Me.Text.Substring(0, iIndex), Me.Font)
Dim i As Integer = MeasureDisplayStringWidth(gr, Me.Text.Substring(0, iIndex), Me.Font)
gr.Dispose()
gr = Nothing
' Windows api call
MyUtilsLib.WindowsAPI.SetCaretPos(i, 1)
End Sub
Public Function MeasureDisplayStringWidth(ByVal gr As Graphics, ByVal text As String, ByVal fnt As Font) As Integer
If text.Length < 1 Then Return 0
Dim format As System.Drawing.StringFormat = New System.Drawing.StringFormat()
Dim rect As System.Drawing.RectangleF = New System.Drawing.RectangleF(0, 0, 1000, 1000)
Dim ranges As System.Drawing.CharacterRange() = {New System.Drawing.CharacterRange(0, text.Length)}
Dim regions As System.Drawing.Region() = {New System.Drawing.Region()}
format.SetMeasurableCharacterRanges(ranges)
regions = gr.MeasureCharacterRanges(text, fnt, rect, format)
rect = regions(0).GetBounds(gr)
Return CInt(rect.Right + 1.0F)
End Function
-- modified 28-Feb-19 15:15pm.
|
|
|
|
|
Not sure if this is the right place to post this.
My VB Winform app works on Win 7 32 bit just fine, and in VS 2017 when developing on my Win10 X64 machine. But when I go to install the app on my machine, it won't access or read the database files. There's no error or exception thrown. It worked before, up until perhaps last December.
Some research suggested that I need the Access Database Engine. So I did download that and installed but no difference. Not really sure which direction to go here. Perhaps I just need to add a file to my Wix installer program. I'm thinking it's the System.Data file that contains OLEDB and I can just add that to the install.
I do have my Wix installer set to X86, because the customer target machines are Win 7 32 bit. But I'm will be selling the new computers that are Win10 X64 so I need to fix this.
Any help or knowledge would be appreciated.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I changed the compile to X86, and choose Debug-Net4.0 and that version works
Tried Release-Net4.0 and that version didn't work
So the debug version works, but not the release
In release mode I get this error - The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine
Oh, I spent many hours working with nLog and integrated it into my windows apps. Just dawned on me to use my logging system to check for errors, Homer Simpson Duh!!!!!
I think I got this now ...
If it ain't broke don't fix it
Discover my world at jkirkerx.com
modified 26-Feb-19 14:47pm.
|
|
|
|
|
|
Message Closed
modified 11-Feb-19 12:17pm.
|
|
|
|
|
Doing so has huge problems. First, if the network connection to where you store the XLAM file goes down, the extension no longer works.
Next, if you screw up the code in the XLAM and put it in the stored location, you break it for EVERYONE.
And, if your code uses COM-based components, you have to install the thing the components anyway because you have to write the registry information used to tell the machine where to find the components and how to run them.
Do yourself, and your customers, a favor and just copy it locally, a.k.a.: install it.
As someone who repackages and deploys software as my primary job, running code from a network share is ROYAL PAIN IN THE ASS!
|
|
|
|
|
Hi Dave,
Thanks for your reply.
Sorry did not noticed your reply so deleted the question posted.
Sorry for deleting the post added.
Thanks
Manju
|
|
|
|
|
Hi Team,
I am trying to split the cells if comma and space .
I tried below code.Its spliting for space now.
How can i change it so that it will check for multiple(both space and comma)
Dim splitvals As Variant
Dim totalVals As Long
Set sh1 = ThisWorkbook.Sheets(1)
Set sh2 = ThisWorkbook.Sheets(2)
sh2.Cells.Clear
lrow1 = sh1.Range("A65356").End(xlUp).Row
For j = 2 To lrow1
splitvals = Split(sh1.Cells(j, 2), " ")
For i = LBound(splitvals) To UBound(splitvals)
lrow2 = sh2.Range("B65356").End(xlUp).Row
lrow3 = sh2.Range("A65356").End(xlUp).Row
sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
sh2.Cells(lrow3 + 1, 2) = splitvals(i)
Next i
Next j
Even i tried:
splitvals = Split(sh1.Cells(j, 2), ", " " ")
Please suggest me .
Thanks
Manju
|
|
|
|
|
Most method calls operate on objects, but your Split call does not appear to be connected to any object. Where is the documentation for that method?
|
|
|
|
|
Dim splitvals As Variant
Dim totalVals As Long
Dim myData As Workbook
Set myData = Workbooks.Open("D:\Test.xlsx")
Set sh1 = myData.Sheets(1)
Set sh2 = myData.Sheets(2)
sh2.Cells.Clear
lrow1 = sh1.Range("A65356").End(xlUp).Row
For j = 2 To lrow1
splitvals = Split(sh1.Cells(j, 2), ",")
For i = LBound(splitvals) To UBound(splitvals)
lrow2 = sh2.Range("B65356").End(xlUp).Row
lrow3 = sh2.Range("A65356").End(xlUp).Row
sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
sh2.Cells(lrow3 + 1, 2) = splitvals(i)
Next i
Next j
Thanks
Sharan
|
|
|
|
|
That is just a repeat of your question. I asked you where the Split method is defined.
|
|
|
|
|
|
Quote: How can i change it so that it will check for multiple(both space and comma)
You can't pass multiple delimiters into VBA Split function.
You have to call Split function again:
For j = 2 To lrow1
splitvals = Split(sh1.Cells(j, 2), " ")
For i = LBound(splitvals) To UBound(splitvals)
lrow2 = sh2.Range("B65356").End(xlUp).Row
lrow3 = sh2.Range("A65356").End(xlUp).Row
sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
sh2.Cells(lrow3 + 1, 2) = splitvals(i)
Next i
splitvals = Split(sh1.Cells(j, 2), ",")
For i = LBound(splitvals) To UBound(splitvals)
lrow2 = sh2.Range("B65356").End(xlUp).Row
lrow3 = sh2.Range("A65356").End(xlUp).Row
sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
sh2.Cells(lrow3 + 1, 2) = splitvals(i)
Next i
Next j
|
|
|
|
|
Guys need some help here i was trying to delete both datagridview and dataset at the same time
but i seems hard to find some result in what i'am doing so may some one can help me please....
here is my code in retrieving data from database :
Try
OpenDatabase()
cqCnn.Open()
Using cmd As New SqlCommand("Select * from baseMergeView where department = '" & tscmddept.Text & "' or fullname Like '%" & tssearch.Text & "%'", cqCnn)
dtmerge = New virualMerge.MergeTableDataTable
Dim adapter As New SqlDataAdapter(cmd)
adapter.Fill(dtmerge)
End Using
DataGridView1.AutoGenerateColumns = False
DataGridView1.DataSource = dtmerge
Catch ex As Exception
MessageBox.Show(ex.Message, "Data", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Finally
CloseDatabase()
cqCnn.Close()
End Try
and here is my code when iam trying to delete the rows at the same time :
tried this one
Dim i As Integer = 0
Do While i < DataGridView1.Rows.Count
If DataGridView1.Rows(i).Cells(0).Value = True Then
Dim item As virualMerge.MergeTableRow = DirectCast(DirectCast(DataGridView1.CurrentRow.DataBoundItem, DataRowView).Row, virualMerge.MergeTableRow)
item.Delete()
DataGridView1.SelectedRows(i).DataBoundItem.Delete()
End If
If i = DataGridView1.Rows.Count Then
Exit Do
End If
i = i + 1
Loop
and this one to :
For x As Integer = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Rows(i).Cells(0).Value = True Then
Dim item As virualMerge.MergeTableRow = DirectCast(DirectCast(DataGridView1.CurrentRow.DataBoundItem, DataRowView).Row, virualMerge.MergeTableRow)
item.Delete()
DataGridView1.SelectedRows(i).DataBoundItem.Delete()
End If
Next
it seems iam going nowhere with this... Please Help
|
|
|
|
|
Hi all,
I need to load an Test.xlxs file form "D" drive and write the same content to new workbook in sheet1.
Add sheet2 in the workbook and filter the workbook and write the filtered into sheet2 to on workbook.
I have tried the below code but its writing to the same input file with sheet2 but not in the new workbook.
Input file will contain
DrinkID Reciepe_Dat
2 Absolute,Enter,Test
3 Decupper,Enter,Test
4 "Absolute
"
Output is having
DrinkID Reciepe_Dat
2 Absolute
2 Enter
2 Test
3 Decupper
3 Enter
3 Test
4 "Absolute
"
but writing to the same input file.
here is my code:
Sub splitbycells()
Dim splitvals As Variant
Dim totalVals As Long
Set sh1 = ThisWorkbook.Sheets(1)
Set sh2 = ThisWorkbook.Sheets(2)
sh2.Cells.Clear
lrow1 = sh1.Range("A65356").End(xlUp).Row
For j = 2 To lrow1
'splitvals = Split(sh1.Cells(j, 2), Chr(10))
splitvals = Split(sh1.Cells(j, 2), ",")
For i = LBound(splitvals) To UBound(splitvals)
lrow2 = sh2.Range("B65356").End(xlUp).Row
lrow3 = sh2.Range("A65356").End(xlUp).Row
sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
sh2.Cells(lrow3 + 1, 2) = splitvals(i)
Next i
Next j
sh2.Range("A1") = "DrinkID"
sh2.Range("B1") = "Reciepe_Dat"
End Sub
Thanks
Sharan
|
|
|
|
|
Where is the code to write the new workbook?
|
|
|
|
|
Hi,
I have updated the code where it loads the file from some path.
And setting it to myData.
Set myData = Workbooks.Open("D:\B_Test.xlsx")
Set sh1 = myData.Sheets(1)
Set sh2 = myData.Sheets(2)
Now how can i change the code so that it writes to a new workbook and and set that to myData.
Set myData = "New WorkBook"
Thanks
Sharan
|
|
|
|
|
You need to create a new Workbook, add some Worksheets and fill in their content, then save the new Workbook. Something like the following (Yes, I know it's C# but the principle is the same):
Excel.Workbook excelWorkBook = excelApp.Workbooks.Add(Type.Missing);
Excel.Worksheet excelWorkSheet = excelWorkBook.Sheets.Add(Type.Missing);
excelWorkSheet.Name = "Sheet1";
int column = 1;
foreach (DataGridViewColumn dgc in dgvVolunteers.Columns)
{
excelWorkSheet.Cells[1, column] = dgc.HeaderCell.Value;
++column;
}
column--;
int row = 2;
foreach (DataGridViewRow dgr in dgvVolunteers.Rows)
{
for (column = 0; column < dgr.Cells.Count; ++column)
{
excelWorkSheet.Cells[row, column + 1] = dgr.Cells[column].Value;
}
row++;
}
excelWorkBook.SaveAs("MyFileName.xlsx");
excelWorkBook.Close();
|
|
|
|
|