Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    str Function (vba 97+ )

    Alan Miller has kindly agreed that we make public a little nit-picking dialogue that has been carried on in private away from the original thread (<post:=687,112>post 687,112</post:> "clean up strings "). I have attached a TXT file of the conversation.
    In essence, VBA allows us to use identifiers which are assigned to in-built functions as programmer identifiers.
    The case in point was "str", which I use as a call to the str function, but which can be used as a data identifier.
    Try pasting and running this code into your favorite VBA application; I have purposely mis-capitalised the identifiers<pre>Sub test()
    Dim sTr As String
    sTr = "This is really weird!"
    MsgBox sTr
    Dim vAl
    vAl = sTr
    MsgBox vAl
    Dim strMine As String
    strMine = vAl(sTr) ' Type mismatch run time error 13
    MsgBox strMine
    End Sub
    </pre>

    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: str Function (vba 97+ )

    In reaction to a remark by Alan Miller in the text file: both CStr and Str are very *old* functions, they were part of Microsoft BASIC in the early 1980's. Str was already present in Altair Basic, written in 1975 by Bill Gates et al., see for example Altair BASIC Reference Manual.

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: str Function (vba 97+ )

    Didn't know that either! That being the case, it must be a very old oversight in the VBE that allows it to slip through.

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •