|
-
Jan 20th, 2007, 01:17 PM
#1
Thread Starter
Junior Member
[RESOLVED] anybody using VB6?i need ur help!!
the question is:
the software should request that the passenger selects a seat number from 1 to 5. if a passenger selects a seat number which is already booked an error messenge should be displayed and the passenger asked to make another seat selection.This process should continue until an available seat is selected.
who can write the code of this bit 4 me? thanks very much!
ps:I have only learnt VB6 for a month, so it is very difficult for me!
-
Jan 20th, 2007, 02:36 PM
#2
Re: anybody using VB6?i need ur help!!
Moved from CodeBank forum (which is for code examples, not questions)
Welcome to VBForums! 
I'm afraid we dont write peoples homework for them, but we will help with specific questions you have.
See how much of it you can do yourself, then ask us for help on specific issues when you get stuck (also showing us the code you have so far).
-
Jan 20th, 2007, 02:43 PM
#3
Thread Starter
Junior Member
Re: anybody using VB6?i need ur help!!
Private Sub cmdseat_Click()
Dim seatnumber As Integer
seat = txtnumber.Text
If seatnumber < 1 And seatnumber > 5 Then
MsgBox ("Please re-enter the seat number")
End If
End Sub
anything wrong with my code?
-
Jan 20th, 2007, 02:56 PM
#4
Re: anybody using VB6?i need ur help!!
If seatnumber < 1 And seatnumber > 5 Then
can never be True. You probably want Or instead of And.
-
Jan 20th, 2007, 03:03 PM
#5
Lively Member
Re: anybody using VB6?i need ur help!!
That code only works once per button click. Try using a Do While Loop instead. For your input mechanism, use Val() to filter out text
-
Jan 20th, 2007, 03:08 PM
#6
Re: anybody using VB6?i need ur help!!
Here is what computafreak and I are talking about
VB Code:
Private Sub cmdseat_Click()
Dim bValid As Boolean
Do Until bValid
If Val(txtnumber.Text) < 1 Or Val(txtnumber.Text) > 5 Then
MsgBox ("Please re-enter the seat number")
Else
bValid = True
End If
Loop
End Sub
-
Jan 20th, 2007, 03:10 PM
#7
Re: anybody using VB6?i need ur help!!
Oh, and
Also to get your code to look like mine in a post do this
[vbcode]
'Your code
[/vbcode]
which will cause it to show up like this.
Last edited by MartinLiss; Jan 20th, 2007 at 03:14 PM.
-
Jan 20th, 2007, 03:11 PM
#8
Thread Starter
Junior Member
Re: anybody using VB6?i need ur help!!
but i havent learnt val bvalid etc.
i dont think i can use that in my code
-
Jan 20th, 2007, 03:15 PM
#9
Re: anybody using VB6?i need ur help!!
Okay then
VB Code:
Private Sub cmdseat_Click()
Do
If txtnumber.Text < "1" Or txtnumber.Text > "5" Then
MsgBox "Please re-enter the seat number"
Else
Exit Do
End If
Loop
End Sub
Last edited by MartinLiss; Jan 20th, 2007 at 03:24 PM.
-
Jan 20th, 2007, 03:21 PM
#10
Thread Starter
Junior Member
Re: anybody using VB6?i need ur help!!
the problem which i dont understand is
if i enter a number 4, assume that number 4 has already been booked by other passenger, how can i write the code that let the software know number 4 has been booked?? that is the point
-
Jan 20th, 2007, 03:25 PM
#11
Thread Starter
Junior Member
Re: anybody using VB6?i need ur help!!
can we use sub-program or parameter passing ???
-
Jan 20th, 2007, 03:39 PM
#12
Re: anybody using VB6?i need ur help!!
Without Boolean flags this is the best I can do
VB Code:
Private Sub cmdseat_Click()
Dim lngIndex As Long
Dim intSeatsTaken As Integer
Do
If txtNumber.Text < "1" Or txtNumber.Text > "5" Then
MsgBox "Please re-enter the seat number"
Else
For lngIndex = 0 To 4
If strTakenSeats(lngIndex) = txtNumber.Text Then
MsgBox "Sorry that seat is already taken"
Exit Do
Else
strTakenSeats(intSeatsTaken) = txtNumber.Text
intSeatsTaken = intSeatsTaken + 1
Exit Do
End If
Next
End If
Loop
End Sub
-
Jan 20th, 2007, 04:35 PM
#13
Thread Starter
Junior Member
Re: anybody using VB6?i need ur help!!
thank you very much! that does help me!
-
Jan 20th, 2007, 04:38 PM
#14
Re: anybody using VB6?i need ur help!!
You're welcome and BTW I should have also posted this piece.
VB Code:
Option Explicit
Private strTakenSeats(4) As String
You can help us now by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|