Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
How do I check that a variable 'contains' something?
eg. myVar = "myfile01203" If myVar contains "myfile" then 'do something End if |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Hi Bruce,
Try something like: Sub Test01() Dim myVar As String ' myVar = "myfile01203" If Len(myVar) 0 Then 'do something, e.g. MsgBox myVar Else 'do something else? End If End Sub --- Regards, Norman "Bruce" wrote in message ... How do I check that a variable 'contains' something? eg. myVar = "myfile01203" If myVar contains "myfile" then 'do something End if |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Not quite what I was thinking. Let me try again.
I want to test whether my Var contains myfile. Any ideas... "Norman Jones" wrote: Hi Bruce, Try something like: Sub Test01() Dim myVar As String ' myVar = "myfile01203" If Len(myVar) 0 Then 'do something, e.g. MsgBox myVar Else 'do something else? End If End Sub --- Regards, Norman "Bruce" wrote in message ... How do I check that a variable 'contains' something? eg. myVar = "myfile01203" If myVar contains "myfile" then 'do something End if |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Hi Bruce,
sStr = "myfile01203" If myVar = sStr Then 'do something, e.g. MsgBox myVar Else 'do something else? End If --- Regards, Norman "Bruce" wrote in message ... Not quite what I was thinking. Let me try again. I want to test whether my Var contains myfile. Any ideas... |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Norman Jones wrote:
Hi Bruce, sStr = "myfile01203" If myVar = sStr Then 'do something, e.g. MsgBox myVar Else 'do something else? End If --- Regards, Norman "Bruce" wrote in message ... Not quite what I was thinking. Let me try again. I want to test whether my Var contains myfile. Any ideas... No, you still dont see what he is saying. sStr= "My dogs name is spot" if sStr contains "spot" then ' do this code end if I havnt any idea how to do this in vba in c its simple if(strstr(sStr, "spot")) { // do code here } I too was looking for this but unfortunately MS doesnt list functions in the help - you have to already know the function name to find it. At least thats my experience. Eric |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Eric,
Ive got it; If myVar like sStr & "*" Then Bruce "Eric" wrote: Norman Jones wrote: Hi Bruce, sStr = "myfile01203" If myVar = sStr Then 'do something, e.g. MsgBox myVar Else 'do something else? End If --- Regards, Norman "Bruce" wrote in message ... Not quite what I was thinking. Let me try again. I want to test whether my Var contains myfile. Any ideas... No, you still dont see what he is saying. sStr= "My dogs name is spot" if sStr contains "spot" then ' do this code end if I havnt any idea how to do this in vba in c its simple if(strstr(sStr, "spot")) { // do code here } I too was looking for this but unfortunately MS doesnt list functions in the help - you have to already know the function name to find it. At least thats my experience. Eric |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Hi Eric,
I think you have the correct interpretation! Sub Test01() Dim myVar As String Dim sStr As String myVar = "myfile01203" sStr = "myfile" myVar = "myfile01203" If InStr(1, myVar, sStr, vbTextCompare) Then 'do something, e.g. MsgBox "myVar contains the substring " & sStr Else MsgBox sStr & " not found" End If End Sub --- Regards, Norman "Eric" wrote in message news:jzvvd.755094$8_6.482955@attbi_s04... Norman Jones wrote: Hi Bruce, sStr = "myfile01203" If myVar = sStr Then 'do something, e.g. MsgBox myVar Else 'do something else? End If --- Regards, Norman "Bruce" wrote in message ... Not quite what I was thinking. Let me try again. I want to test whether my Var contains myfile. Any ideas... No, you still dont see what he is saying. sStr= "My dogs name is spot" if sStr contains "spot" then ' do this code end if I havnt any idea how to do this in vba in c its simple if(strstr(sStr, "spot")) { // do code here } I too was looking for this but unfortunately MS doesnt list functions in the help - you have to already know the function name to find it. At least thats my experience. Eric |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
so, if
myVar="spot" sStr= "My dogs name is spot" then If myVar like sStr & "*" Then ' code will be executed here for sure? end if I dont get the & "*" thing, whats that mean? Eric Bruce wrote: Eric, Ive got it; If myVar like sStr & "*" Then Bruce "Eric" wrote: Norman Jones wrote: Hi Bruce, sStr = "myfile01203" If myVar = sStr Then 'do something, e.g. MsgBox myVar Else 'do something else? End If --- Regards, Norman "Bruce" wrote in message ... Not quite what I was thinking. Let me try again. I want to test whether my Var contains myfile. Any ideas... No, you still dont see what he is saying. sStr= "My dogs name is spot" if sStr contains "spot" then ' do this code end if I havnt any idea how to do this in vba in c its simple if(strstr(sStr, "spot")) { // do code here } I too was looking for this but unfortunately MS doesnt list functions in the help - you have to already know the function name to find it. At least thats my experience. Eric |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Norman Jones wrote:
Hi Eric, I think you have the correct interpretation! Sub Test01() Dim myVar As String Dim sStr As String myVar = "myfile01203" sStr = "myfile" myVar = "myfile01203" If InStr(1, myVar, sStr, vbTextCompare) Then 'do something, e.g. MsgBox "myVar contains the substring " & sStr Else MsgBox sStr & " not found" End If End Sub --- Regards, Norman Is that case sensitive? if so how do you ignore case? if not how do you make it case specific? Thanks Eric |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
usings contains in var check
Hi Eric,
Is that case sensitive? No. if not how do you make it case specific? If InStr(1, myVar, sStr, vbBinaryCompare) Then --- Regards, Norman "Eric" wrote in message news:w%vvd.190497$V41.190304@attbi_s52... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Increase size of a Forms Check Box (click on to enter check mark) | Excel Discussion (Misc queries) | |||
Usings Text fields in a Pivot Table | Excel Discussion (Misc queries) | |||
Check if Conditional Format is True or False / Check cell Color | Excel Worksheet Functions | |||
Enable check box in protected sheet + group check boxes | Excel Discussion (Misc queries) | |||
how can I perform trig. functions usings grads 400deg per circle | Excel Worksheet Functions |