ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Custom msgbox help needed!!! (https://www.excelbanter.com/excel-programming/379083-custom-msgbox-help-needed.html)

zz

Custom msgbox help needed!!!
 
hi everyone, it's me again buggin off with me little project that's driving
me insane.

this time is somthing i just like to call a nice feature in my VBA based
app.

i hace created a custom msgbox that show a different image depending on the
typeofmsg parameter i pass into a function

i kindda declare my function like follows:



public function showmsg (msg as string,title as string, typeofmsg as
integer)


into the function you can see [ actually not yet, til i finish my project]

'/// important, i set the frmMsg properties because i use the same userform
everytime i need to display a msg.


frmMsg.LblMsg.caption=Msg '// this is the message displayed

frmMsg.Caption= title ' // this is the title of my custom Msgbox

'// here i select if the typeofmsg is equal to an errormsg or a wrningmsg or
an allOKmsg
select case typeofmsg
case is =1
frmMsg.Pct.Picture=IMG1 ' //IMG1 is an object containing the errormsg
image
case is =2
frmMsg.Pct.Picture=IMG2 ' //IMG2 is an object containing the wrningmsg
image
case is =3
frmMsg.Pct.Picture=IMG3 ' //IMG3 is an object containing the allOKmsg
image

end select



till this point everything works just fine

every time i call showmsg("Crap!","Told you!!",1)


the nice popup windows does it's job.


but now i need an extra from this lil ' fellow, i need it to return a
value, like the regular msgbox

EG,

when i say X=msgbox("dude!, what are you smokin' ?, are you for real??
",VByesnocancel,"be aware, your files will be deleted!!!")

i can know if X=VByes or X=VBno

so now, i need ideas about implementing this in my function


any help will be welcome!!!!


thanks in advantage!!


--
---
zz [MX]
cuasi-musico,semi-poeta y loco




Simon Lloyd[_903_]

Custom msgbox help needed!!!
 

Hi not sure entirely what you want to do but this is how to make use of
Yes, No and Cancel from a message box:


Code:
--------------------
Sub Mbox()
Select Case MsgBox("What Now", vbYesNoCancel, "Decision Maker")
Case vbYes
MsgBox "Good"
Case vbNo
MsgBox "Bad"
Case vbCancel
MsgBox "Ugly"
End Select

End Sub
--------------------
Hope this helps,
Regards,
Simon


--
Simon Lloyd

zz

Custom msgbox help needed!!!
 
thanks for the reply but i have already figured it out !!!...

if anybody wants to know how send me an email to
Jarious[dot]com[at]gmail[dot]com


--
---
zz [MX]
cuasi-musico,semi-poeta y loco

"Simon Lloyd" wrote in
message ...

Hi not sure entirely what you want to do but this is how to make use of
Yes, No and Cancel from a message box:


Code:
--------------------
Sub Mbox()
Select Case MsgBox("What Now", vbYesNoCancel, "Decision Maker")
Case vbYes
MsgBox "Good"
Case vbNo
MsgBox "Bad"
Case vbCancel
MsgBox "Ugly"
End Select

End Sub
--------------------
Hope this helps,
Regards,
Simon


--
Simon Lloyd




Tom Ogilvy

Custom msgbox help needed!!!
 
You mean if I was reading this thread and I wanted to find out the solution,
I would need to send an email to





Doesn't seem like that is in the spirit of the newsgroup?

--
Regards,
Tom Ogilvy



"zz" wrote in message
...
thanks for the reply but i have already figured it out !!!...

if anybody wants to know how send me an email to
Jarious[dot]com[at]gmail[dot]com


--
---
zz [MX]
cuasi-musico,semi-poeta y loco

"Simon Lloyd" wrote in
message ...

Hi not sure entirely what you want to do but this is how to make use of
Yes, No and Cancel from a message box:


Code:
--------------------
Sub Mbox()
Select Case MsgBox("What Now", vbYesNoCancel, "Decision Maker")
Case vbYes
MsgBox "Good"
Case vbNo
MsgBox "Bad"
Case vbCancel
MsgBox "Ugly"
End Select

End Sub
--------------------
Hope this helps,
Regards,
Simon


--
Simon Lloyd






zz

Custom msgbox help needed!!!
 
well, thanks for all the spam i will get.[ no hard feelings]


i am completely sorry if that was the impression i caused, of course i do
not mean breaking the spirit of the group, no, sorry again.


Bad zz !! bad zz !!, no cookies for you tonight!!!



so for my redemption.


'// i know it has some 'scratches' and it could have been a little bit more
effective, but i'm under a little pressure to finish this '//before xmas and
as long as it works...




in a regular module called msgs i declared this function



Public returnanswer As Integer ' ///this is a global variable that can be
set from Frmmsg's events

Public Function Messagebox(Msg As String, Title As String, typeofmsg As
Integer) As String

On Error GoTo errhandler

Load Frmmsg '// this loads the userform that 'acts' as the msgbox but
doesn't show it yet

Frmmsg.lblmsg.Caption = Msg '// places the message

Frmmsg.Caption = Title ' // sets the title ,obviously


Select Case typeofmsg
Case Is = 1
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgwarn.jpg") '// show
the 'yellow message sphere

Case Is = 2
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgerr.jpg") '// show
the
' red sphere pic

Case Is = 3
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgsuccess.jpg") '//
show
'the green sphere pic

End Select

Frmmsg.Show

'// this part is for the Messagebox to return a value that
can be handled like the VByes response in a regular msgbox

Select Case msgs.returnanswer

Case Is = 1
Messagebox= "TByes"
Case Is = 2
Messagebox = "TBNot"
Case Is = 3
Messagebox = "TBcancel"
End Select

errhandler:
Err.Clear
End Function



Now


in the Frmmsg i have three buttons one for yes, another for no and a
third for cancel




private sub Btntbyes_onclick

msgs.returnanswer=1 '// this is for the Messagebox function to return
"TByes"

unload frmmsg '// cause we don't need the msg anymore

end sub


private sub Btntbnot_onclick

msgs.returnanswer=2 '// this is for the Messagebox function to return "TBno"

unload frmmsg '// cause we don't need the msg anymore

end sub

private sub Btntbcancel_onclick

msgs.returnanswer=3 '// this is for the Messagebox function to return
"TBcancel"

unload frmmsg '// cause we don't need the msg anymore

end sub



so now i can write


X= Messagebox("Wow " & application.username & " you're handsome!! " &
VbCrlf & " am i right?" ,"Self esteem enhancer",3)
if x="TByes"
then
Messagebox "Liar!!!!","Go back to work",2
else
Messagebox "c'mon!, you know youre not but i still like you the best ","
Please return to your activities",3
endif

actually this is not the purpose for what i use it, but i tought this would
be funnier.


Best regards, hope it may be usefull.


--
:=)
---
zz [MX]
cuasi-musico,semi-poeta y loco



"Tom Ogilvy" wrote in message
...
You mean if I was reading this thread and I wanted to find out the
solution, I would need to send an email to





Doesn't seem like that is in the spirit of the newsgroup?

--
Regards,
Tom Ogilvy



"zz" wrote in message
...
thanks for the reply but i have already figured it out !!!...

if anybody wants to know how send me an email to
Jarious[dot]com[at]gmail[dot]com


--
---
zz [MX]
cuasi-musico,semi-poeta y loco

"Simon Lloyd" wrote
in message ...

Hi not sure entirely what you want to do but this is how to make use of
Yes, No and Cancel from a message box:


Code:
--------------------
Sub Mbox()
Select Case MsgBox("What Now", vbYesNoCancel, "Decision Maker")
Case vbYes
MsgBox "Good"
Case vbNo
MsgBox "Bad"
Case vbCancel
MsgBox "Ugly"
End Select

End Sub
--------------------
Hope this helps,
Regards,
Simon


--
Simon Lloyd








Tom Ogilvy

Custom msgbox help needed!!!
 
I wouldn't be too concerned about "all the spam". I have been posting here
for 9 years using an unprotected email address and wouldn't consider the
amount of SPAM I get to be any big deal.

Using a public variable is pretty standard fare. Unfortunately, you made it
sound like you had a major discovery.

but thanks for posting your solution! - I am sure it will be useful for
many.

--
Regards,
Tom Ogilvy


"zz" wrote in message
...
well, thanks for all the spam i will get.[ no hard feelings]


i am completely sorry if that was the impression i caused, of course i do
not mean breaking the spirit of the group, no, sorry again.


Bad zz !! bad zz !!, no cookies for you tonight!!!



so for my redemption.


'// i know it has some 'scratches' and it could have been a little bit
more effective, but i'm under a little pressure to finish this '//before
xmas and as long as it works...




in a regular module called msgs i declared this function



Public returnanswer As Integer ' ///this is a global variable that can
be set from Frmmsg's events

Public Function Messagebox(Msg As String, Title As String, typeofmsg As
Integer) As String

On Error GoTo errhandler

Load Frmmsg '// this loads the userform that 'acts' as the msgbox but
doesn't show it yet

Frmmsg.lblmsg.Caption = Msg '// places the message

Frmmsg.Caption = Title ' // sets the title ,obviously


Select Case typeofmsg
Case Is = 1
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgwarn.jpg") '// show
the 'yellow message sphere

Case Is = 2
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgerr.jpg") '// show
the
' red sphere pic

Case Is = 3
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgsuccess.jpg") '//
show
'the green sphere pic

End Select

Frmmsg.Show

'// this part is for the Messagebox to return a value that
can be handled like the VByes response in a regular msgbox

Select Case msgs.returnanswer

Case Is = 1
Messagebox= "TByes"
Case Is = 2
Messagebox = "TBNot"
Case Is = 3
Messagebox = "TBcancel"
End Select

errhandler:
Err.Clear
End Function



Now


in the Frmmsg i have three buttons one for yes, another for no and a
third for cancel




private sub Btntbyes_onclick

msgs.returnanswer=1 '// this is for the Messagebox function to return
"TByes"

unload frmmsg '// cause we don't need the msg anymore

end sub


private sub Btntbnot_onclick

msgs.returnanswer=2 '// this is for the Messagebox function to return
"TBno"

unload frmmsg '// cause we don't need the msg anymore

end sub

private sub Btntbcancel_onclick

msgs.returnanswer=3 '// this is for the Messagebox function to return
"TBcancel"

unload frmmsg '// cause we don't need the msg anymore

end sub



so now i can write


X= Messagebox("Wow " & application.username & " you're handsome!! " &
VbCrlf & " am i right?" ,"Self esteem enhancer",3)
if x="TByes"
then
Messagebox "Liar!!!!","Go back to work",2
else
Messagebox "c'mon!, you know youre not but i still like you the best ","
Please return to your activities",3
endif

actually this is not the purpose for what i use it, but i tought this
would be funnier.


Best regards, hope it may be usefull.


--
:=)
---
zz [MX]
cuasi-musico,semi-poeta y loco



"Tom Ogilvy" wrote in message
...
You mean if I was reading this thread and I wanted to find out the
solution, I would need to send an email to





Doesn't seem like that is in the spirit of the newsgroup?

--
Regards,
Tom Ogilvy



"zz" wrote in message
...
thanks for the reply but i have already figured it out !!!...

if anybody wants to know how send me an email to
Jarious[dot]com[at]gmail[dot]com


--
---
zz [MX]
cuasi-musico,semi-poeta y loco

"Simon Lloyd" wrote
in message ...

Hi not sure entirely what you want to do but this is how to make use of
Yes, No and Cancel from a message box:


Code:
--------------------
Sub Mbox()
Select Case MsgBox("What Now", vbYesNoCancel, "Decision Maker")
Case vbYes
MsgBox "Good"
Case vbNo
MsgBox "Bad"
Case vbCancel
MsgBox "Ugly"
End Select

End Sub
--------------------
Hope this helps,
Regards,
Simon


--
Simon Lloyd









zz

Custom msgbox help needed!!!
 
yah, i dont mind too much for the spam, gmail's filter works pretty fine.

well and , it is a major discovery to me in my very personal way, i do not
know too much about VBA or VB or XL, and everything i know is thanks to
everybody here, and i am sure that here are some enthusiasts that are
'discovering' this tool just like me, and i thougth it would be nice to
share this with them.

guess it shouldn't be a great discovery to you, since you are a great expert
on this subject...

but wath the hell, it is like glory to me when something i had never done
before works well.

regards.


--
---
zz [MX]
cuasi-musico,semi-poeta y loco


"Tom Ogilvy" wrote in message
...
I wouldn't be too concerned about "all the spam". I have been posting here
for 9 years using an unprotected email address and wouldn't consider the
amount of SPAM I get to be any big deal.

Using a public variable is pretty standard fare. Unfortunately, you made
it sound like you had a major discovery.

but thanks for posting your solution! - I am sure it will be useful for
many.

--
Regards,
Tom Ogilvy


"zz" wrote in message
...
well, thanks for all the spam i will get.[ no hard feelings]


i am completely sorry if that was the impression i caused, of course i do
not mean breaking the spirit of the group, no, sorry again.


Bad zz !! bad zz !!, no cookies for you tonight!!!



so for my redemption.


'// i know it has some 'scratches' and it could have been a little bit
more effective, but i'm under a little pressure to finish this '//before
xmas and as long as it works...




in a regular module called msgs i declared this function



Public returnanswer As Integer ' ///this is a global variable that can
be set from Frmmsg's events

Public Function Messagebox(Msg As String, Title As String, typeofmsg As
Integer) As String

On Error GoTo errhandler

Load Frmmsg '// this loads the userform that 'acts' as the msgbox but
doesn't show it yet

Frmmsg.lblmsg.Caption = Msg '// places the message

Frmmsg.Caption = Title ' // sets the title ,obviously


Select Case typeofmsg
Case Is = 1
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgwarn.jpg") '//
show the 'yellow message sphere

Case Is = 2
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgerr.jpg") '// show
the
' red sphere pic

Case Is = 3
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgsuccess.jpg") '//
show
'the green sphere pic

End Select

Frmmsg.Show

'// this part is for the Messagebox to return a value that
can be handled like the VByes response in a regular msgbox

Select Case msgs.returnanswer

Case Is = 1
Messagebox= "TByes"
Case Is = 2
Messagebox = "TBNot"
Case Is = 3
Messagebox = "TBcancel"
End Select

errhandler:
Err.Clear
End Function



Now


in the Frmmsg i have three buttons one for yes, another for no and a
third for cancel




private sub Btntbyes_onclick

msgs.returnanswer=1 '// this is for the Messagebox function to return
"TByes"

unload frmmsg '// cause we don't need the msg anymore

end sub


private sub Btntbnot_onclick

msgs.returnanswer=2 '// this is for the Messagebox function to return
"TBno"

unload frmmsg '// cause we don't need the msg anymore

end sub

private sub Btntbcancel_onclick

msgs.returnanswer=3 '// this is for the Messagebox function to return
"TBcancel"

unload frmmsg '// cause we don't need the msg anymore

end sub



so now i can write


X= Messagebox("Wow " & application.username & " you're handsome!! " &
VbCrlf & " am i right?" ,"Self esteem enhancer",3)
if x="TByes"
then
Messagebox "Liar!!!!","Go back to work",2
else
Messagebox "c'mon!, you know youre not but i still like you the best
"," Please return to your activities",3
endif

actually this is not the purpose for what i use it, but i tought this
would be funnier.


Best regards, hope it may be usefull.


--
:=)
---
zz [MX]
cuasi-musico,semi-poeta y loco



"Tom Ogilvy" wrote in message
...
You mean if I was reading this thread and I wanted to find out the
solution, I would need to send an email to





Doesn't seem like that is in the spirit of the newsgroup?

--
Regards,
Tom Ogilvy



"zz" wrote in message
...
thanks for the reply but i have already figured it out !!!...

if anybody wants to know how send me an email to
Jarious[dot]com[at]gmail[dot]com


--
---
zz [MX]
cuasi-musico,semi-poeta y loco

"Simon Lloyd" wrote
in message ...

Hi not sure entirely what you want to do but this is how to make use
of
Yes, No and Cancel from a message box:


Code:
--------------------
Sub Mbox()
Select Case MsgBox("What Now", vbYesNoCancel, "Decision Maker")
Case vbYes
MsgBox "Good"
Case vbNo
MsgBox "Bad"
Case vbCancel
MsgBox "Ugly"
End Select

End Sub
--------------------
Hope this helps,
Regards,
Simon


--
Simon Lloyd











Tom Ogilvy

Custom msgbox help needed!!!
 
I said thanks for posting your solution and that it would be useful.

--
Regards,
Tom Ogilvy

"zz" wrote in message
...
yah, i dont mind too much for the spam, gmail's filter works pretty fine.

well and , it is a major discovery to me in my very personal way, i do not
know too much about VBA or VB or XL, and everything i know is thanks to
everybody here, and i am sure that here are some enthusiasts that are
'discovering' this tool just like me, and i thougth it would be nice to
share this with them.

guess it shouldn't be a great discovery to you, since you are a great
expert on this subject...

but wath the hell, it is like glory to me when something i had never done
before works well.

regards.


--
---
zz [MX]
cuasi-musico,semi-poeta y loco


"Tom Ogilvy" wrote in message
...
I wouldn't be too concerned about "all the spam". I have been posting
here for 9 years using an unprotected email address and wouldn't consider
the amount of SPAM I get to be any big deal.

Using a public variable is pretty standard fare. Unfortunately, you made
it sound like you had a major discovery.

but thanks for posting your solution! - I am sure it will be useful for
many.

--
Regards,
Tom Ogilvy


"zz" wrote in message
...
well, thanks for all the spam i will get.[ no hard feelings]


i am completely sorry if that was the impression i caused, of course i
do not mean breaking the spirit of the group, no, sorry again.


Bad zz !! bad zz !!, no cookies for you tonight!!!



so for my redemption.


'// i know it has some 'scratches' and it could have been a little bit
more effective, but i'm under a little pressure to finish this '//before
xmas and as long as it works...




in a regular module called msgs i declared this function



Public returnanswer As Integer ' ///this is a global variable that can
be set from Frmmsg's events

Public Function Messagebox(Msg As String, Title As String, typeofmsg As
Integer) As String

On Error GoTo errhandler

Load Frmmsg '// this loads the userform that 'acts' as the msgbox but
doesn't show it yet

Frmmsg.lblmsg.Caption = Msg '// places the message

Frmmsg.Caption = Title ' // sets the title ,obviously


Select Case typeofmsg
Case Is = 1
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgwarn.jpg") '//
show the 'yellow message sphere

Case Is = 2
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgerr.jpg") '//
show the
' red sphere pic

Case Is = 3
Frmmsg.typeofmsj.Picture =
LoadPicture("R:\Trainbox\Tbxclient\resources\Image s\Msgsuccess.jpg") '//
show
'the green sphere pic

End Select

Frmmsg.Show

'// this part is for the Messagebox to return a value
that can be handled like the VByes response in a regular msgbox

Select Case msgs.returnanswer

Case Is = 1
Messagebox= "TByes"
Case Is = 2
Messagebox = "TBNot"
Case Is = 3
Messagebox = "TBcancel"
End Select

errhandler:
Err.Clear
End Function



Now


in the Frmmsg i have three buttons one for yes, another for no and a
third for cancel




private sub Btntbyes_onclick

msgs.returnanswer=1 '// this is for the Messagebox function to return
"TByes"

unload frmmsg '// cause we don't need the msg anymore

end sub


private sub Btntbnot_onclick

msgs.returnanswer=2 '// this is for the Messagebox function to return
"TBno"

unload frmmsg '// cause we don't need the msg anymore

end sub

private sub Btntbcancel_onclick

msgs.returnanswer=3 '// this is for the Messagebox function to return
"TBcancel"

unload frmmsg '// cause we don't need the msg anymore

end sub



so now i can write


X= Messagebox("Wow " & application.username & " you're handsome!! " &
VbCrlf & " am i right?" ,"Self esteem enhancer",3)
if x="TByes"
then
Messagebox "Liar!!!!","Go back to work",2
else
Messagebox "c'mon!, you know youre not but i still like you the best
"," Please return to your activities",3
endif

actually this is not the purpose for what i use it, but i tought this
would be funnier.


Best regards, hope it may be usefull.


--
:=)
---
zz [MX]
cuasi-musico,semi-poeta y loco



"Tom Ogilvy" wrote in message
...
You mean if I was reading this thread and I wanted to find out the
solution, I would need to send an email to





Doesn't seem like that is in the spirit of the newsgroup?

--
Regards,
Tom Ogilvy



"zz" wrote in message
...
thanks for the reply but i have already figured it out !!!...

if anybody wants to know how send me an email to
Jarious[dot]com[at]gmail[dot]com


--
---
zz [MX]
cuasi-musico,semi-poeta y loco

"Simon Lloyd"
wrote in message
...

Hi not sure entirely what you want to do but this is how to make use
of
Yes, No and Cancel from a message box:


Code:
--------------------
Sub Mbox()
Select Case MsgBox("What Now", vbYesNoCancel, "Decision Maker")
Case vbYes
MsgBox "Good"
Case vbNo
MsgBox "Bad"
Case vbCancel
MsgBox "Ugly"
End Select

End Sub
--------------------
Hope this helps,
Regards,
Simon


--
Simon Lloyd














All times are GMT +1. The time now is 08:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com