W
W. Adam
I have a form which displays info. On top of it there is a text box for
input box which lets you put number from 1 thu 112.I need to verify that
the
number entered by the user is within the range of 1-12. If it isn't, notify
the user and set the focus back to the text box. Do not allow processing to
continue until a valid entry is entered in the textbox.
How can i achive that
Thanks in advance
Here is my code whats wrong with it?
Private Sub btnDisplayGifts_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnDisplayGifts.Click
Dim intI, intJ, intNumDays, intDays As Integer
Dim strName, number As String
Dim dblPrice, dblTotalCost, dblGrandTotal As Double
Dim strSr As IO.StreamReader = IO.File.OpenText("Xmas.txt")
intNumDays = CInt(txtNumDays.Text)
If intNumDays <= 0 And intNumDays > 12 Then
Do
MsgBox("Please enter 1 thru 12 ", , " Number of Days")
txtNumDays.Text = ""
txtNumDays.Focus()
Loop Until (intNumDays > 0 And intNumDays < 12)
lstTable.Items.Clear()
lstTable.Items.Add("The gift for the day" & " " & intNumDays & " " & "are:")
End If
lstTable.Items.Clear()
lstTable.Items.Add("The gift for the day" & " " & intDays & " " & "are:")
For intI = 1 To intDays
strName = strSr.ReadLine
dblPrice = CDbl(strSr.ReadLine)
dblTotalCost += dblPrice * intI
lstTable.Items.Add(intI & "." & " " & strName)
Next
lstTable.Items.Add("Cost:" & "" & FormatCurrency(dblTotalCost, 2))
lstTable.Items.Add("")
strSr.Close()
End Sub
input box which lets you put number from 1 thu 112.I need to verify that
the
number entered by the user is within the range of 1-12. If it isn't, notify
the user and set the focus back to the text box. Do not allow processing to
continue until a valid entry is entered in the textbox.
How can i achive that
Thanks in advance
Here is my code whats wrong with it?
Private Sub btnDisplayGifts_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnDisplayGifts.Click
Dim intI, intJ, intNumDays, intDays As Integer
Dim strName, number As String
Dim dblPrice, dblTotalCost, dblGrandTotal As Double
Dim strSr As IO.StreamReader = IO.File.OpenText("Xmas.txt")
intNumDays = CInt(txtNumDays.Text)
If intNumDays <= 0 And intNumDays > 12 Then
Do
MsgBox("Please enter 1 thru 12 ", , " Number of Days")
txtNumDays.Text = ""
txtNumDays.Focus()
Loop Until (intNumDays > 0 And intNumDays < 12)
lstTable.Items.Clear()
lstTable.Items.Add("The gift for the day" & " " & intNumDays & " " & "are:")
End If
lstTable.Items.Clear()
lstTable.Items.Add("The gift for the day" & " " & intDays & " " & "are:")
For intI = 1 To intDays
strName = strSr.ReadLine
dblPrice = CDbl(strSr.ReadLine)
dblTotalCost += dblPrice * intI
lstTable.Items.Add(intI & "." & " " & strName)
Next
lstTable.Items.Add("Cost:" & "" & FormatCurrency(dblTotalCost, 2))
lstTable.Items.Add("")
strSr.Close()
End Sub