It is my first time, using this forum:
I have a project: it has too be smart device application , using loop to get entry and if the entry is not numeric give an error,and if the number of entry is also more than 20 , it has to give another error,....
my loop works well, calculation is ok.
but my data validation has problem, i was working near 7 hours but i could not figure out.
i was wondering if you can help me....
(the application has to get speed and hours of travel, and has to show the distance in each hour)
Thankss..
here are my codes
'Author : Pouria Norasteh
'Date: 10-06-2007
'Program to calculate the distance in each hour
Public Class Form1
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Me.Close()
End Sub
Private Sub btncalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalculate.Click
Dim decspeed As Integer
Dim inthours As Integer
Dim dblanswer As Double
Dim intindex As Integer
Dim intstart As Integer = 1
decspeed = Me.txtvehiclespeed.Text()
decspeed = Convert.ToString(decspeed)
inthours = Me.txtboxnumberofhours.Text()
inthours = Convert.ToString(inthours)
If Not IsNumeric(decspeed) Or Not IsNumeric(inthours) Then
MessageBox.Show("Wrong Entry", "Enter a Positive Number")
Me.txtvehiclespeed.Text = ""
Me.txtvehiclespeed.Focus()
Me.txtboxnumberofhours.Text = ""
End If
If inthours > 20 Or inthours = 0 Then
MessageBox.Show("Enter a Positive Number less than 20", "Wrong Entry")
Me.txtboxnumberofhours.Focus()
Me.txtboxnumberofhours.Text = ""
Me.txtvehiclespeed.Text = ""
Me.lsttxtLstbox.Visible = False
End If
For intindex = intstart To inthours
dblanswer = (intindex) * (decspeed)
Me.lsttxtLstbox.Items.Add("Hour" & intindex & " = " & dblanswer)
Next
Me.btncalculate.Enabled = False
Me.lblnumberofhours.Enabled = False
Me.lblspeed.Enabled = False
Me.lsttxtLstbox.Enabled = True
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Me.txtboxnumberofhours.Text = ""
Me.txtvehiclespeed.Text = ""
Me.lsttxtLstbox.Items.Clear()
Me.btncalculate.Enabled = True
Me.lblspeed.Enabled = True
Me.lblnumberofhours.Enabled = True
Me.lblnumberofhours.Visible = True
Me.lsttxtLstbox.Visible=True
End Sub
End Class

New Topic/Question
This topic is locked




MultiQuote


|