Results 1 to 9 of 9

Thread: instr help [resolved]

  1. #1

    Thread Starter
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152

    instr help [resolved]

    VB Code:
    1. ' still workin on this function :(
    2. Private Function CheckmyList()
    3. Dim i As Integer
    4. Dim mystr As String
    5. mystr = Text6
    6. For i = 0 To List1.ListCount - 1
    7. If InStr(mystr, List1.List(i)) Then
    8. SEND "The command has been sent, " & mystr & "!"
    9. Else
    10. SEND "Sorry, " & mystr & " but you do not have access!"
    11. End If
    12. Next
    13. End Function

    well i have a listbox and im searching thru it.... now see if mystr is in the listbox then it will send "the command has been send" ...this part worx.. but it never sends the "sorry u dont have access" part .. even when mystr isnt in the list

    what did i do wrong?
    Last edited by ice_531; Jul 8th, 2004 at 09:54 PM.
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  2. #2

  3. #3

    Thread Starter
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    Still doesnt send the other one ... if mystr isnt in list1.

    I thought the way i had it was saying...

    " if we can find mystr in the list then we send this but if we cant then we will send THAT"

    but instead its being mean and saying...

    "If we can find mystr in the list then we send this but if we cant o well...."

    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    OK, try something like this which works for me.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.  
    5.     CheckmyList
    6.    
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10. List1.AddItem "I am Sam I am"
    11. List1.AddItem "And Joe is here"
    12. End Sub
    13.  
    14. Private Function CheckmyList()
    15. Dim i As Integer
    16. Dim mystr As String
    17. mystr = Text6
    18. For i = 0 To List1.ListCount - 1
    19.     If InStr(UCase(List1.List(i)), UCase(mystr)) Then
    20.         MsgBox "The command has been sent, " & mystr & "!"
    21.         Exit For
    22.     Else
    23.         MsgBox "Sorry, " & mystr & " but you do not have access!"
    24.         Exit For
    25.     End If
    26. Next
    27. End Function

  5. #5

    Thread Starter
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    Well i tried a new project w/ that code and THAT works. but in my current project it seems to not work still.

    i dunno what in my code is making it ignore sending after else. i can just make another function and have it check by:
    if not instr(blah,blah1.list(i)) then
    send the other

    ?
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  6. #6

  7. #7

    Thread Starter
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    VB Code:
    1. ' still workin on this function :(
    2. Private Function CheckmyList()
    3. Dim i As Integer
    4. Dim mystr As String
    5. mystr = Text6
    6. For i = 0 To List1.ListCount - 1
    7. If InStr(UCase(List1.List(i)), UCase(mystr)) Then
    8. SEND "The command has been executed for you, " & mystr & "!"
    9. Exit For
    10. Else
    11. SEND "Sorry, " & mystr & " but you do not have access to this command!"
    12. Exit For
    13. End If
    14. Next
    15. End Function
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

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

    VB Code:
    1. Private Function CheckmyList()
    2. Dim i As Integer
    3. Dim mystr As String
    4. Dim bFound As Boolean
    5. mystr = Text6
    6. For i = 0 To List1.ListCount - 1
    7.     If InStr(UCase(List1.List(i)), UCase(mystr)) Then
    8.         MsgBox "The command has been sent, " & mystr & "!"
    9.         bFound = True
    10.         Exit For
    11.     End If
    12. Next
    13. If Not bFound Then
    14.     MsgBox "Sorry, " & mystr & " but you do not have access!"
    15. End If
    16. End Function

  9. #9

    Thread Starter
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    Wee. it worx fine now!

    Thanks Martin
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

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