Results 1 to 7 of 7

Thread: ! operator instead of . (why?)

  1. #1

    Thread Starter
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    consider the following:
    Code:
    frmDrawDlg!txtAspectheight.Visible = false
    now consider:
    Code:
    frmDrawDlg.txtAspectheight.Visible = False
    Both of the above statements work, but...

    Q. Why use an exclamation mark instead of a dot?



    Answers on a postcard please to:

    24 Crispin hasn't woken up yet Street
    Springfield
    90243

    Thanks in advance guys.
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Recordsets.

    If a field name contains a space (or similar - not that u you would ever do this, right? ), it needs to be protected from big bad world by square brackets or quotes. You can't use a dot woth these

    eg

    rs![A Test] works

    rs.[A test] doesn't.

    The it seems you can use exclamations to point to objects, and dots to reference methods and some objects
    (that last bit may be a bit spurious!)

  3. #3
    Addicted Member AngelinaM's Avatar
    Join Date
    Jan 2001
    Location
    Tampa, Florida
    Posts
    175

    Then...

    What is the difference between:

    rs("A Test") and rs![A Test]

  4. #4

    Thread Starter
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Gaffer,

    Thanks!, i've used the recordset stuff before, I had never seen objects or methods referenced by an exclamation, always a dot (wierd)
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  5. #5
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186
    Early binding and late binding. Using the fullstop is late bound and therefor slower. That is as far as Recordsets are concerned.

    I'm not sure about forms, although I do know that some other objects are slower if you use "." instead of "!"

    Shrog
    VB6 Ent SP5
    Win2000

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    data1.recordset.myField = text1
    or
    data1!myfield = text1

    the ! in this instance is a shortcut
    you can omit the reference to the recordset
    as the ! implies a recordset follows the control

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7

    Thread Starter
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    I have no problem with the recordset syntax (I don't have a problem with any of it for that matter) I am interested as to why it is used (and for what specific reason (if any)) for referencing objects in forms, like textboxes e.t.c If it's early binding vs late binding then I can appreciate that, but is anybody really sure about this one:

    Form.textbox.caption = "I am sure"

    Vs

    Form!textbox.caption = "Or am I?"


    I don't know of anything in the IDispatch interface that qualifies dispID's in different ways, I reckon i might be barking up the wrong tree......






    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

Posting Permissions

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



Click Here to Expand Forum to Full Width