Results 1 to 14 of 14

Thread: [RESOLVED] anybody using VB6?i need ur help!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    26

    Resolved [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!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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).

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    26

    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?

  4. #4

  5. #5
    Lively Member
    Join Date
    Oct 2006
    Posts
    88

    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

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: anybody using VB6?i need ur help!!

    Here is what computafreak and I are talking about

    VB Code:
    1. Private Sub cmdseat_Click()
    2.  
    3. Dim bValid As Boolean
    4.  
    5. Do Until bValid
    6.     If Val(txtnumber.Text) < 1 Or Val(txtnumber.Text) > 5 Then
    7.         MsgBox ("Please re-enter the seat number")
    8.     Else
    9.         bValid = True
    10.     End If
    11. Loop
    12.  
    13. End Sub

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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.
    VB Code:
    1. ' Your code

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    26

    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

  9. #9
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: anybody using VB6?i need ur help!!

    Okay then

    VB Code:
    1. Private Sub cmdseat_Click()
    2.  
    3. Do
    4.     If txtnumber.Text < "1" Or txtnumber.Text > "5" Then
    5.         MsgBox "Please re-enter the seat number"
    6.     Else
    7.         Exit Do
    8.     End If
    9. Loop
    10.  
    11. End Sub

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    26

    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

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    26

    Re: anybody using VB6?i need ur help!!

    can we use sub-program or parameter passing ???

  12. #12
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: anybody using VB6?i need ur help!!

    Without Boolean flags this is the best I can do

    VB Code:
    1. Private Sub cmdseat_Click()
    2.  
    3. Dim lngIndex As Long
    4. Dim intSeatsTaken As Integer
    5.  
    6. Do
    7.     If txtNumber.Text < "1" Or txtNumber.Text > "5" Then
    8.         MsgBox "Please re-enter the seat number"
    9.     Else
    10.         For lngIndex = 0 To 4
    11.             If strTakenSeats(lngIndex) = txtNumber.Text Then
    12.                 MsgBox "Sorry that seat is already taken"
    13.                 Exit Do
    14.             Else
    15.                 strTakenSeats(intSeatsTaken) = txtNumber.Text
    16.                 intSeatsTaken = intSeatsTaken + 1
    17.                 Exit Do
    18.             End If
    19.         Next
    20.     End If
    21. Loop
    22.  
    23. End Sub

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    26

    Re: anybody using VB6?i need ur help!!

    thank you very much! that does help me!

  14. #14
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: anybody using VB6?i need ur help!!

    You're welcome and BTW I should have also posted this piece.

    VB Code:
    1. Option Explicit
    2. 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
  •  



Click Here to Expand Forum to Full Width