Teen Programmers Unite  
 

 

Return to forum top

VB6 MsgBox()

Posted by andymcnab [send private reply] at June 18, 2002, 12:19:58 PM

Hello, i am doing a scripting languge in VB6 and need to know how to modify the properties of a msgbox at runtime.
Thanx
EG. Title, Prompt, Icon?????????

Posted by metamorphic [send private reply] at June 18, 2002, 04:17:11 PM

title and prompt can be done using variables. The icon can only be one of the set few.

dim strprompt as string
dim strtitle as string
strprompt = "This is a prompt"
strtitle = "MSGBOX Title"
msgbox strprompt, vbcritical, title


would make a critical-style message box saying "this is a prompt" with the title "MSGBOX Title".

to change the icon either use a select case or allow the user to type in vbcritical or vbyesno or whatever and substitute it in.
Posted by jbman [send private reply] at June 25, 2002, 01:04:53 AM

Actually, to edit message boxes from runtime, you would need to create a few variables. Lets say, you want the user to have their own message. You could create a textbox with the name txtMessage. THen create a command button lets just say its called cmdMsgBox. The code to trigger the message box is:

Private Sub cmdMsgBox()

Dim intResults As Integer
Dim strMessage As String

strMessage = txtMessage.text
'This is to set the text box as the variable 'strMessage'

intResults = MsgBox (strMessage, [buttons go here], "[title goes in here")
End Sub
#####################
There are many options that go with the msgbox. Buttons can be "vbOKOnly" for just an ok button - or "vbYesNo" for yes and no. To interpret the answer - you must look up the values they return. This code is setup so whatever value returned is stored in intResults. You can create an If...End If statement to choose what to do next. For MsgBox return values, check your VB Help section.

Any Questions? Email jebarth1@aol.com
Thanks!
Jb


Posted by buzgub [send private reply] at June 25, 2002, 04:08:07 AM

You can't actually modify the properties (which are not even properties in the VB lingo); you can just set them when you call the MsgBox function. Look up said function in the help file.

Posted by jbman [send private reply] at June 25, 2002, 11:32:33 AM

right

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.