944,183 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 2024
  • VB.NET RSS
Jan 12th, 2007
0

Having trouble Subtracting 3 digit #'s help!

Expand Post »
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)


Public
Class 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
Similar Threads
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
WhYuLoOkIn is offline Offline
55 posts
since Jan 2007
Jan 13th, 2007
0

Re: Having trouble Subtracting 3 digit #'s help!

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.

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
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Jan 13th, 2007
0

Re: Having trouble Subtracting 3 digit #'s help!

Thanks alot, I really appreciate the help that you all offer. I have been trying to figure that one out for a week.
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
WhYuLoOkIn is offline Offline
55 posts
since Jan 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: VB Blacvkjack Homework
Next Thread in VB.NET Forum Timeline: Listview Data to XML or file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC