|
-
Jul 8th, 2004, 08:40 PM
#1
Thread Starter
Frenzied Member
instr help [resolved]
VB Code:
' still workin on this function :(
Private Function CheckmyList()
Dim i As Integer
Dim mystr As String
mystr = Text6
For i = 0 To List1.ListCount - 1
If InStr(mystr, List1.List(i)) Then
SEND "The command has been sent, " & mystr & "!"
Else
SEND "Sorry, " & mystr & " but you do not have access!"
End If
Next
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++
-
Jul 8th, 2004, 08:48 PM
#2
I believe you have inStr backward.
If InStr(List1.List(i),mystr) Then
-
Jul 8th, 2004, 08:52 PM
#3
Thread Starter
Frenzied Member
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++
-
Jul 8th, 2004, 09:31 PM
#4
OK, try something like this which works for me.
VB Code:
Option Explicit
Private Sub Command1_Click()
CheckmyList
End Sub
Private Sub Form_Load()
List1.AddItem "I am Sam I am"
List1.AddItem "And Joe is here"
End Sub
Private Function CheckmyList()
Dim i As Integer
Dim mystr As String
mystr = Text6
For i = 0 To List1.ListCount - 1
If InStr(UCase(List1.List(i)), UCase(mystr)) Then
MsgBox "The command has been sent, " & mystr & "!"
Exit For
Else
MsgBox "Sorry, " & mystr & " but you do not have access!"
Exit For
End If
Next
End Function
-
Jul 8th, 2004, 09:40 PM
#5
Thread Starter
Frenzied Member
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++
-
Jul 8th, 2004, 09:43 PM
#6
Please show your code as you have it now.
-
Jul 8th, 2004, 09:45 PM
#7
Thread Starter
Frenzied Member
VB Code:
' still workin on this function :(
Private Function CheckmyList()
Dim i As Integer
Dim mystr As String
mystr = Text6
For i = 0 To List1.ListCount - 1
If InStr(UCase(List1.List(i)), UCase(mystr)) Then
SEND "The command has been executed for you, " & mystr & "!"
Exit For
Else
SEND "Sorry, " & mystr & " but you do not have access to this command!"
Exit For
End If
Next
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++
-
Jul 8th, 2004, 09:48 PM
#8
Nevermind, my mistake.
VB Code:
Private Function CheckmyList()
Dim i As Integer
Dim mystr As String
Dim bFound As Boolean
mystr = Text6
For i = 0 To List1.ListCount - 1
If InStr(UCase(List1.List(i)), UCase(mystr)) Then
MsgBox "The command has been sent, " & mystr & "!"
bFound = True
Exit For
End If
Next
If Not bFound Then
MsgBox "Sorry, " & mystr & " but you do not have access!"
End If
End Function
-
Jul 8th, 2004, 09:53 PM
#9
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|