+ 1
!!! How can I fix this??
Exception Unhandled System.InvalidCastException: 'Conversion from string "to type Integer' is not valid. Inner Exception FormatException: Input string was not in a correct format.
7 odpowiedzi
+ 5
Plz share your code
+ 1
Public Sub my1() ListBox3.Items.clear() Dim 1, m, b As Integer Dim r, h, p As String htxtH. Text p txtP. Text For i0 To ListBox2. Items.Count 1 b Math.Tan (ListBox1. Items (i))r(9.8 (r (ListBox2. Items (1) * Math. Cos (ListBox1.Items (i)))) If h And ( h + p ) > # b Then ListBox3. Items.Add("oAxoAMT") Else ListBox3. Items.Add ("He noAxoAWT") End If Next lblRez.Text m End Sub Private Sub btnAdd Click(ByVal sender As System.Object, ByVal e As System. EventArgs) Handles btnAdd.Click Dim inputname,a inputnameInputBox("BBeAnTe A 1 (parameter) sender As Object If IsNumeric(a)True And a<Then ListBox1.Items.Add(inputname) ListBox2.Items.Add(a) End If Call my1() End Sub
+ 1
The code you sent is not C#, it is VB.
+ 1
Sorry my fault
+ 1
So
Whats the mistake
+ 1
I tried to write
Dim r,h, p, l, m, b, As Integer
But still shows that mistake
+ 1
I don't know VB, but I know C#. I can't tell you where is the mistake, but I can tell you what is wrong and how to fix it, inshaAllah. Error says that you have something that can't be convertible to int in your string variable. Examples:
"1m"->It cannot be convertible to int.
"12"->It can be convertible to int.
You can set a breakpoint in your solution to see where is this exception throwed.