simple question
-
I have a string which should have either the substring ID in it, or the substring ID_NUMBER (it looks like
s = abc;adf;ID;ghj;ID_NUMBER;jjj
if at least one of these values is there, then I want to continue. But if neither is there, I want to exit the function. I've done:
If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then MakeDB = -1 Exit Function End If
but I think I'm wrong. :confused::confused: Thanks, ns
-
I have a string which should have either the substring ID in it, or the substring ID_NUMBER (it looks like
s = abc;adf;ID;ghj;ID_NUMBER;jjj
if at least one of these values is there, then I want to continue. But if neither is there, I want to exit the function. I've done:
If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then MakeDB = -1 Exit Function End If
but I think I'm wrong. :confused::confused: Thanks, ns
ns wrote: If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then If it doesn't find "ID" then it isn't going to find "ID_NUMBER". I think that
Or
is wrong anyway but it's not even necessary,If Not InStr(s, "ID") Then
would suffice. As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a> 0
to be sure. Paul -
ns wrote: If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then If it doesn't find "ID" then it isn't going to find "ID_NUMBER". I think that
Or
is wrong anyway but it's not even necessary,If Not InStr(s, "ID") Then
would suffice. As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a> 0
to be sure. Paul -
ns wrote: If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then If it doesn't find "ID" then it isn't going to find "ID_NUMBER". I think that
Or
is wrong anyway but it's not even necessary,If Not InStr(s, "ID") Then
would suffice. As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a> 0
to be sure. PaulPaul Riley wrote: As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a > 0 to be sure. VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. :) Nick Parker
**The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
**
-
Paul Riley wrote: As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a > 0 to be sure. VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. :) Nick Parker
**The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
**
Nick Parker wrote: VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. I guess this is what comes of using many different languages that all act differently, you get to the point where you don't trust any of them and end up being as specific as possible at all times. C(++) has left me using parentheses absolutely everywhere :laugh:. This is all a good thing, in my humblest opinion. More precise coding is more readable coding. Contrary to popular opinion, it is possible to code VB well ;) Paul
-
Nick Parker wrote: VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. I guess this is what comes of using many different languages that all act differently, you get to the point where you don't trust any of them and end up being as specific as possible at all times. C(++) has left me using parentheses absolutely everywhere :laugh:. This is all a good thing, in my humblest opinion. More precise coding is more readable coding. Contrary to popular opinion, it is possible to code VB well ;) Paul
Paul Riley wrote: Contrary to popular opinion, it is possible to code VB well Fully agreed, I suppose we should watch how we talk about VB here in C++ country though. :laugh: :cool: Nick Parker
**The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
**