View Full Version : Need help with my Visual Basic homework.


Ike-One
10-20-2006, 01:28 PM
I'm suppose do this:

"Write a Do While loop that uses an input box to ask the user to enter a number. The loop should keep runnning total of the numbers entered and stop when the total is greater than 300."



This is the code I have to work with:

Public Class lblList

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strInput As String

If lstMonths.SelectedIndex = -1 Then
MessageBox.Show("Select a month")
ElseIf lstYears.SelectedIndex = -1 Then
MessageBox.Show("Select a year")
Else
strInput = lstMonths.SelectedItem.ToString() & " " _
& lstYears.SelectedItem.ToString()
MessageBox.Show("You selected" & strInput)
End If

End Sub
End Class


I would post this in the homework section, but given the circumstances of the subject... yeah.

Ike-One
10-20-2006, 02:00 PM
Actually, I think the above statement is completely irrelevant... I'm gonna slap the person who told me I had to use that snippet... I'm just going to try to rewrite the entire code.

Ike-One
10-20-2006, 03:54 PM
Sorry for posting in a row...

I ended up writing this:

Dim intCount As Integer = 0
Dim strInput As String
Dim a As Integer
Dim y As Integer

strInput = InputBox("Enter a number")
a = CInt(strInput)
y += a

Do While y < 300

Loop

D^Coy
10-20-2006, 04:03 PM
Actually, I think the above statement is completely irrelevant... I'm gonna slap the person who told me I had to use that snippet... I'm just going to try to rewrite the entire code.lmfao...i was just about to say that!