Re: Very Confused On IIF
From: Jonathan Wood (jwood_at_softcircuits.com)
Date: 03/24/04
- Next message: Jonathan Wood: "Re: Very Confused On IIF"
- Previous message: Frank Carr: "Re: programmer career"
- In reply to: Michael Harrington: "Very Confused On IIF"
- Next in thread: Jonathan Wood: "Re: Very Confused On IIF"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 23 Mar 2004 18:08:26 -0700
While Left$(
-- Jonathan Wood SoftCircuits http://www.softcircuits.com Available for consulting: http://www.softcircuits.com/jwood/resume.htm "Michael Harrington" <mikeh@inetprovider.com> wrote in message news:Oa9z4LSEEHA.240@tk2msftngp13.phx.gbl... > Okay everyone, here's one for ya..... I have a statement using the "IIF" > function and it fails, but if I break it apart into a traditional If-Then > statement, it works fine. Can anyone tell me what the difference is, or if > this is a bug in VB6? I get "Invalid procedure call or argument > > ---- NON-WORKING IIF VERSION ---- > > Public Sub Main() > Debug.Print BracketsRemove("123456") 'Works > Debug.Print BracketsRemove("[123456]") 'Works > Debug.Print BracketsRemove("[1]") 'Works > Debug.Print BracketsRemove("1") 'THE ERROR IS HERE > End Sub > > Private Function BracketsRemove(ByVal sString As String) As String > BracketsRemove = IIf(Mid$(sString, 1, 1) = "[", Mid$(sString, 2, > Len(sString) - 2), sString) > End Function > > ---- WORKING IF-THEN VERSION ---- > > Public Sub Main() > Debug.Print BracketsRemove("123456") 'Works > Debug.Print BracketsRemove("[123456]") 'Works > Debug.Print BracketsRemove("[1]") 'Works > Debug.Print BracketsRemove("1") 'NO ERROR NOW! > End Sub > > Private Function BracketsRemove(ByVal sString As String) As String > If Mid$(sString, 1, 1) = "[" Then > BracketsRemove = Mid$(sString, 2, Len(sString) - 2) > Else > BracketsRemove = sString > End If > End Function > >
- Next message: Jonathan Wood: "Re: Very Confused On IIF"
- Previous message: Frank Carr: "Re: programmer career"
- In reply to: Michael Harrington: "Very Confused On IIF"
- Next in thread: Jonathan Wood: "Re: Very Confused On IIF"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|