!!! How can I fix this?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

25th Feb 2019, 9:40 AM
Boburi
7 Answers
+ 5
Plz share your code
25th Feb 2019, 10:40 AM
Rstar
Rstar - avatar
+ 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
25th Feb 2019, 10:50 AM
Boburi
+ 1
The code you sent is not C#, it is VB.
25th Feb 2019, 11:13 AM
Yusuf
Yusuf - avatar
+ 1
Sorry my fault
25th Feb 2019, 11:17 AM
Boburi
+ 1
So Whats the mistake
25th Feb 2019, 11:18 AM
Boburi
+ 1
I tried to write Dim r,h, p, l, m, b, As Integer But still shows that mistake
25th Feb 2019, 11:20 AM
Boburi
+ 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.
25th Feb 2019, 11:47 AM
Yusuf
Yusuf - avatar