Re: VB Riddle, Simplified


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Re: VB Riddle, Simplified

  1. #1
    Bruno Paris Guest

    Re: VB Riddle, Simplified

    I simplified the puzzle:

    First line runs OK. The second fails.
    **** Q: How is this possible? ****

    ' Here is complete code (there is no other code
    ' in the form or elsewhere)
    Option Explicit

    Private Sub Form_Click()
    Caption = MsgBox("Hello", vbOKOnly)
    Caption = MsgBox("Hehe", vbOKOnly) ' <<< ERROR!
    End Sub






  2. #2
    Donald Xie Guest

    Re: VB Riddle, Simplified

    Technically, I can make Caption a write-once property such as

    Private mCaption As String
    Public Property Let Caption(RHS As String)
    If (mCaption = "") Then
    mCaption = RHS
    Else
    ' Raise an error
    End If
    End Property

    Do I have a prize?

    Don

    Bruno Paris <nospam_ameba@zg.tel.hr> wrote in message
    news:38e729eb@news.devx.com...
    > I simplified the puzzle:
    >
    > First line runs OK. The second fails.
    > **** Q: How is this possible? ****
    >
    > ' Here is complete code (there is no other code
    > ' in the form or elsewhere)
    > Option Explicit
    >
    > Private Sub Form_Click()
    > Caption = MsgBox("Hello", vbOKOnly)
    > Caption = MsgBox("Hehe", vbOKOnly) ' <<< ERROR!
    > End Sub
    >
    >
    >
    >
    >




  3. #3
    Bruno Paris Guest

    Re: VB Riddle, Simplified

    Hi, Don
    No prize. Caption is read-write property of the form.
    There is no other code in the form. There are no other modules in the
    project. Also, I didn't add any reference (.DLL or .OCX) to the
    project.

    Bruno

    Donald Xie wrote:
    >Technically, I can make Caption a write-once property such as
    >
    >Private mCaption As String
    >Public Property Let Caption(RHS As String)
    > If (mCaption = "") Then
    > mCaption = RHS
    > Else
    > ' Raise an error
    > End If
    >End Property
    >
    >Do I have a prize?
    >
    >Don





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center