Results 1 to 16 of 16

Thread: Small Problem...

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Melbourne, Australia
    Posts
    40

    Small Problem...

    A simple problem that i cannontcrack, and its just annoying me. The user must enter a lane number for an athlete

    i want it to say:

    On button Click
    Store Lane in ListBox
    Check If Lane already entered
    MsgBox("Lane Already Entered")
    else store lane
    End If

    how can i check if it has already been entered? what should the correct coding be

    lstLane is the name of lstBox
    iLane is Lane Number
    do i need a counter?
    Cheers

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Small Problem...

    Maybe add the entered value into an array and then check the array everytime the user goes to enter a new value - alert them if its already there else allow them to continue....


    Just an idea

    Cheers,

    RyaNJ
    My Blog.

    Ryan Jones.

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Small Problem...

    If you have a button for each lane, as you select the lane, just disable the button so that it can't be selected again.

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Melbourne, Australia
    Posts
    40

    Re: Small Problem...

    How do i store/call from that array though?
    Im sorry, still only new to programming and getting the hold of it

    should it be something like:

    dim iLane(11) as integer
    then how do you store and call from the array to check?
    Cheers

  5. #5
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Small Problem...

    Quote Originally Posted by dglienna
    If you have a button for each lane, as you select the lane, just disable the button so that it can't be selected again.

    Thats a more interesting way to do it


    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  6. #6

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Melbourne, Australia
    Posts
    40

    Re: Small Problem...

    Yeah but i dont have a button for each lane, and i cant do it like that. The end user must enter the lane and have it validated... im sorry, any ideas on the code???

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Small Problem...

    You could even have the person's name in the disbled button.

    Anyways, what are your button's purpose? What controls are you using besides a button?

  8. #8

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Melbourne, Australia
    Posts
    40

    Re: Small Problem...

    Basically the user enteres a name, a time the person swum, and the lane the person was in.
    When the button is pressed, it stores the values in three seperate listboxes.
    All i want it to do, is check if the lane has already been entered into the listbox, and if it has, then display an error message to re-enter lane number.
    Does this explain it?
    Cheers

  9. #9
    Member
    Join Date
    Apr 2005
    Posts
    39

    Re: Small Problem...

    Let me answer this question people! Just a minute though i gotta see if it works.

  10. #10

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Melbourne, Australia
    Posts
    40

    Re: Small Problem...

    Ok Cheers mate, any solutions???

  11. #11
    Member
    Join Date
    Apr 2005
    Posts
    39

    Re: Small Problem...

    GOT IT! Just a minute i should have it in a minute!

  12. #12
    Member
    Join Date
    Apr 2005
    Posts
    39

    Re: Small Problem...

    Woot! here you go bud... fresh from the kitchen.

    Dim x As String
    Dim y As Integer

    MsgBox List1.ListCount
    For y = 0 To (List1.ListCount - 1)

    List1.ListIndex = y
    x = List1.Text
    MsgBox x
    If x = "Grey" Then
    MsgBox "beeer"
    End If
    Next y

  13. #13
    Member
    Join Date
    Apr 2005
    Posts
    39

    Re: Small Problem...

    Quote Originally Posted by littleman001
    Woot! here you go bud... fresh from the kitchen.

    Dim x As String
    Dim y As Integer

    MsgBox List1.ListCount
    For y = 0 To (List1.ListCount - 1)

    List1.ListIndex = y
    x = List1.Text
    MsgBox x
    If x = "Grey" Then
    MsgBox "beeer"
    End If
    Next y

    just start a new program up and insert this text into a command button and also insert a list button you should get it from there

  14. #14
    Member
    Join Date
    Apr 2005
    Posts
    39

    Re: Small Problem...

    Please let me know if it works or not! common man im waitin

  15. #15

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Melbourne, Australia
    Posts
    40

    Re: Small Problem...

    When i put it in to a code,
    it says ListIndex is not a member of System.Windows.Forms.ListBox
    or the same for ListCount
    Do i have to declare these somewhere?
    I dont understand

  16. #16
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Small Problem...

    looks like you wandered into the wrong forum by mistake. that looks like 'Net code. this is the vbforum.

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