-
VB Riddle
Hi, all
I have only one form in my project. When I click on my form, statement
'a' will set caption to "1", but statement 'b' gives run-time error.
Q: How is this possible?
Option Explicit
Private Sub Form_Click()
Dim style As VbMsgBoxStyle
style = vbExclamation Or vbOKCancel
Caption = MsgBox("Hello", style) ' this line works OK
style = vbExclamation Or vbOKOnly
Caption = MsgBox("Hehe", style) ' <<<< ERROR
End Sub
Have fun!
Bruno
-
Re: VB Riddle
Sorry, I forgot the labels:
Option Explicit
Private Sub Form_Click()
Dim style As VbMsgBoxStyle
style = vbExclamation Or vbOKCancel
a: Caption = MsgBox("Hello", style) ' this line works OK
style = vbExclamation Or vbOKOnly
b: Caption = MsgBox("Hehe", style) ' <<<< ERROR
End Sub
Bruno Paris wrote:
>Hi, all
>I have only one form in my project. When I click on my form,
statement
>'a' will set caption to "1", but statement 'b' gives run-time error.
>Q: How is this possible?
....
-
Re: VB Riddle
Bruno Paris <nospam_ameba@zg.tel.hr> wrote in message
news:38e5d0d4@news.devx.com...
> Sorry, I forgot the labels:
>
> Option Explicit
>
> Private Sub Form_Click()
> Dim style As VbMsgBoxStyle
>
> style = vbExclamation Or vbOKCancel
> a: Caption = MsgBox("Hello", style) ' this line works OK
>
> style = vbExclamation Or vbOKOnly
> b: Caption = MsgBox("Hehe", style) ' <<<< ERROR
> End Sub
>
>
> Bruno Paris wrote:
> >Hi, all
> >I have only one form in my project. When I click on my form,
> statement
> >'a' will set caption to "1", but statement 'b' gives run-time error.
> >Q: How is this possible?
> ...
Using VB6 with SP3 this runs fine for me. I would make two suggestions to
(IMHO) improve the readability and stability of the code:
a: Me.Caption=CStr(Msgbox("Hello",style))
b: Me.Caption=CStr(Msgbox("Hehe",style))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|