Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you create a message box

Status
Not open for further replies.

lostINtheSAUCE

Programmer
Dec 14, 2001
2
0
0
US
I working on a project for class and I need to make a box that well display the message...

"Select drive directory from below"

I tried using a label box but it wont work....How do I create a message box??
 
Do you need a box to select the drive from on the message box? If so, make a form how you want it, set the border property to vbFixedDialog, and show it with Form.Show vbModal. You can find all the icons that you can use in standard 'msgbox' boxes in the graphics folder somewhere.

To disable the close button, try this code, courtesy of John Percival: (I found this at
Declarations

Paste this into the declaration section:

Code:
Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long

Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long

Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long

Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Public Const MF_BYPOSITION = &H400&
Public Const MF_REMOVE = &H1000&
Form Code

Then paste this into the form:

Private Sub Form_Load()
Dim hSysMenu As Long
Dim nCnt As Long

'First, show the form
Me.Show

'Get handle to our form's system menu 
'(Restore, Maximize, Move, close etc.)
hSysMenu = GetSystemMenu(Me.hwnd, False)

If hSysMenu Then
'Get System menu's menu count
nCnt = GetMenuItemCount(hSysMenu)

If nCnt Then

'Menu count is based on 0 (0, 1, 2, 3...)

RemoveMenu hSysMenu, nCnt - 1, _
MF_BYPOSITION Or MF_REMOVE

RemoveMenu hSysMenu, nCnt - 2, _
MF_BYPOSITION Or MF_REMOVE 'Remove the seperator

DrawMenuBar Me.hwnd 
'Force caption bar's refresh. Disabling X button

Me.Caption = "Try to close me!"
End If
End If
End Sub
 
HI there
it is like this
You can use the Default visual basic message box
Just follow the code
the keyword "msgbox" will do it
Just type the keyword where you want the message to appear and the following syntax like msgbox("your message,title,etc")

/Revanth
 
Yeah, you mean just like what 75Cl said at the beginning... :)
 
Just copy and paste this code in between your sub and end sub routine that you wish to use, for instance a command button
------------------------------------------------------------
sub commandbutton1_click()
Dim Msg, Title, Responce

Msg = "Use the message you want to display here."
Title = "Here you type in a title for the title bar message"

responce = msgbox(msg,vbYesNo,title)

if responce=vbyes then end

end sub

------------------------------------------------------------
just copy and paste the code between the lines above, hope this helps you out, you can put what ever message you want in between the quotes of MSG variable and the Title variable

ok bye bye now :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top