| | |
Having trouble Subtracting 3 digit #'s help!
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
I am using Visual Basic Express, I hope you all still can help me. This program is used to calculate a cars speed related to speed limit. It has two user inputs, cars speed and speed limit. It will calculate any two digit # and one digit #, but when I input a three digit # the output comes out as 0. Please Help!!! (Just trying to learn, Thank You)
PublicClass Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Double = 0 '// Declaring Variabe as Integer Data Type
If TextBox1.Text > TextBox2.Text Then '// If Box 1 is greater than box 2
Do While i < Double.Parse(TextBox1.Text - TextBox2.Text) '// while i(which is equal to zero) is less than our integer, Box 1 - Box 2
i += 1 '// i = i + 1, 0 = 0 + 1 ?????
Loop
MessageBox.Show("The Calculated speed is " & i.ToString() & " miles under the speed limit.") '// Message in our MessageBox
TextBox1.Text = ""
TextBox2.Text = ""
Else
If TextBox1.Text < TextBox2.Text Then
Do While i < Double.Parse(TextBox2.Text - TextBox1.Text) '// while i(which is equal to zero) is less than our integer, Box 2 - Box 1
i += 1 '// i = i + 1, 0 = 0 + 1 ?????
Loop
MessageBox.Show("The Calculated speed is " & i.ToString() & " miles over the speed limit.") '// Message in our MessageBox
TextBox1.Text = ""
TextBox2.Text = ""
End If
End If
End Sub
EndClass
PublicClass Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Double = 0 '// Declaring Variabe as Integer Data Type
If TextBox1.Text > TextBox2.Text Then '// If Box 1 is greater than box 2
Do While i < Double.Parse(TextBox1.Text - TextBox2.Text) '// while i(which is equal to zero) is less than our integer, Box 1 - Box 2
i += 1 '// i = i + 1, 0 = 0 + 1 ?????
Loop
MessageBox.Show("The Calculated speed is " & i.ToString() & " miles under the speed limit.") '// Message in our MessageBox
TextBox1.Text = ""
TextBox2.Text = ""
Else
If TextBox1.Text < TextBox2.Text Then
Do While i < Double.Parse(TextBox2.Text - TextBox1.Text) '// while i(which is equal to zero) is less than our integer, Box 2 - Box 1
i += 1 '// i = i + 1, 0 = 0 + 1 ?????
Loop
MessageBox.Show("The Calculated speed is " & i.ToString() & " miles over the speed limit.") '// Message in our MessageBox
TextBox1.Text = ""
TextBox2.Text = ""
End If
End If
End Sub
EndClass
Hi,
Where u r inputting 3rd Digit..?
I think this would suffice, U dont have to put in a Loop, to Calculate the Difference between 2 Values.
Regards
Veena
Where u r inputting 3rd Digit..?
I think this would suffice, U dont have to put in a Loop, to Calculate the Difference between 2 Values.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Double If Val(TextBox1.Text) > Val(TextBox2.Text) Then i = Val(TextBox1.Text) - Val(TextBox2.Text) Else i = Val(TextBox2.Text) - Val(TextBox1.Text) End If MsgBox("The Calculated speed is " & i.ToString() ) End Sub
Regards
Veena
![]() |
Similar Threads
- Hotmail Access Trouble (Web Browsers)
- C++:three-digit number all odd, eve, or both (C++)
- Trouble opening certain files... (Windows 95 / 98 / Me)
- Cubing Digits Individually (C++)
- sims trouble (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: VB Blacvkjack Homework
- Next Thread: Listview Data to XML or file
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access arithmetic array assignment basic binary bing box button buttons c# center code combobox component connectionstring convert data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net excel file-dialog firewall folder google hardcopy image images isnumericfuntioncall listview login math memory mobile ms mssqlbackend mysql navigate net networking opacity output pan peertopeervideostreaming picturebox picturebox1 plugin port print printing printpreview problemwithinstallation project record reports" reuse save savedialog serial server sorting sql storedprocedure string structures studio temp text textbox timer toolbox updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view visual visualbasic visualbasic.net visualstudio web wpf





