| | |
Custom Message Box
![]() |
Err... Why don't you just make a new form (frmMsgBox)?
You can just do something like:
You can change frmMsgBox!Text1 = "" to whatever you want the message to say. You can add buttons, an icon, etc to it.
Does that work?
You can just do something like:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
frmMsgBox!Text1 = "Testing, 1,2,3" Load frmMsgBox frmMsgBox.Show
You can change frmMsgBox!Text1 = "" to whatever you want the message to say. You can add buttons, an icon, etc to it.
Does that work?
Toshiba M115 ● 1.49 GB DDR-2 RAM ● 1.6 GHz Centrino Duo ● 80GB HDD ● Windows XP Media Center Edition
•
•
Join Date: Mar 2007
Posts: 20
Reputation:
Solved Threads: 0
I did exactly what you are talking about doing and made it an ActiveX dll using VB6. This is a message box with four large buttons. When you call the message box, you pass in the title for the message box window and you also pass in at least one string value for the button captions, and up to four string values to cover all the button captions. This function will then pass the value back that was pressed.
I'm using one class module and one form module. Here's the code I'm using:
cMsgBoxes Class Module Code:
frmMsgBox4Button Form Module Code:
Here's how I'm using this dll. I just keep it in the directory of my .exe or my VBScript file. No need to register this dll if you do that. I've compiled the project with the project name "MsgBoxes" and named the dll "MsgBoxes.dll". In my code I use late binding:
VBScript:
I'm using one class module and one form module. Here's the code I'm using:
cMsgBoxes Class Module Code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Public Function MsgBox4Button(strTitle As String, strcmd1 As String, Optional strcmd2 As String = " ", Optional strcmd3 As String = " ", Optional strcmd4 As String = " ") As String With frmMsgBox4Button .Caption = strTitle .cmd1.Caption = strcmd1 .cmd2.Caption = strcmd2 .cmd3.Caption = strcmd3 .cmd4.Caption = strcmd4 If Trim(.cmd2.Caption) = "" Then .cmd2.Visible = False If Trim(.cmd3.Caption) = "" Then .cmd3.Visible = False If Trim(.cmd4.Caption) = "" Then .cmd4.Visible = False End With frmMsgBox4Button.Show 1 MsgBox4Button = frmMsgBox4Button.Response Unload frmMsgBox4Button End Function
frmMsgBox4Button Form Module Code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Public Response As String Private Sub cmd1_Click() Response = cmd1.Caption Me.Hide End Sub Private Sub cmd2_Click() Response = cmd2.Caption Me.Hide End Sub Private Sub cmd3_Click() Response = cmd3.Caption Me.Hide End Sub Private Sub cmd4_Click() Response = cmd4.Caption Me.Hide End Sub
Here's how I'm using this dll. I just keep it in the directory of my .exe or my VBScript file. No need to register this dll if you do that. I've compiled the project with the project name "MsgBoxes" and named the dll "MsgBoxes.dll". In my code I use late binding:
VBScript:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim objMsgBox, MyMsgBox Set objMsgBox = CreateObject("MsgBoxes.cMsgBoxes") MyMsgBox = objMsgBox.MsgBox4Button("What would you like to do?", "Go to work.", "Go Home.", "Go hang.") MsgBox MyMsgBox Set objMsgBox = Nothing
•
•
Join Date: Jan 2008
Posts: 1
Reputation:
Solved Threads: 0
0
#7 Jan 29th, 2008
i make a program with vb, this program about making a store .
i have a simple problem with this program
want to make a message box that can ok and cancelthat connect with a database to show some records from a tabel as sequential.
but i cannot make this button do its functions to be ok or cancel
can any one help me
this is the code of button that show the records:
Private Sub Command1_Click()
Dim conConnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rstRecordSet As New ADODB.Recordset
Dim urmsg As Integer
conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\" & "min requirements.mdb;Mode=Read|Write"
conConnection.CursorLocation = adUseClient
conConnection.Open
With cmdCommand
.ActiveConnection = conConnection
.CommandText = "SELECT * FROM dealers;"
.CommandType = adCmdText
End With
With rstRecordSet
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmdCommand
End With
If rstRecordSet.EOF = False Then
rstRecordSet.MoveFirst
Do
urmsg = MsgBox("ÈíÇäÇÊ ÇáÓÌá" & rstRecordSet.AbsolutePosition & " " & _
rstRecordSet.Fields(0).Name & "=" & rstRecordSet.Fields(0) & " " & _
rstRecordSet.Fields(1).Name & "=" & rstRecordSet.Fields(1) & " " & _
rstRecordSet.Fields(2).Name & "=" & rstRecordSet.Fields(2) & " " & _
rstRecordSet.Fields(3).Name & "=" & rstRecordSet.Fields(3), vbOKCancel, "ÚÑÖ ÇáÚãáÇÁ")
rstRecordSet.MoveNext
Loop Until rstRecordSet.EOF = True
Select Case urmsg
Case 6 'If the user clicks "Yes" then...
rstRecordSet.MoveNext 'Quit the program
Case 7 'If the user click on No....
Exit Sub 'Then Exit the sub, not the program.
End Select
'With rstRecordSet
' .AddNew
' .Fields(0) = "New"
' .Fields(1) = "Record"
' .Update
'End With
'rstRecordSet.MoveFirst
'rstRecordSet.Delete
'rstRecordSet.Update
'rstRecordSet.Close
Else
MsgBox "Nn records were returned ushng the query " & cmdCommand.CommandText
End If
conConnection.Close
Set conConnection = Nothing
Set cmdCommand = Nothing
Set rstRecordSet = Nothing
End Sub
i have a simple problem with this program
want to make a message box that can ok and cancelthat connect with a database to show some records from a tabel as sequential.
but i cannot make this button do its functions to be ok or cancel
can any one help me
this is the code of button that show the records:
Private Sub Command1_Click()
Dim conConnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rstRecordSet As New ADODB.Recordset
Dim urmsg As Integer
conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\" & "min requirements.mdb;Mode=Read|Write"
conConnection.CursorLocation = adUseClient
conConnection.Open
With cmdCommand
.ActiveConnection = conConnection
.CommandText = "SELECT * FROM dealers;"
.CommandType = adCmdText
End With
With rstRecordSet
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmdCommand
End With
If rstRecordSet.EOF = False Then
rstRecordSet.MoveFirst
Do
urmsg = MsgBox("ÈíÇäÇÊ ÇáÓÌá" & rstRecordSet.AbsolutePosition & " " & _
rstRecordSet.Fields(0).Name & "=" & rstRecordSet.Fields(0) & " " & _
rstRecordSet.Fields(1).Name & "=" & rstRecordSet.Fields(1) & " " & _
rstRecordSet.Fields(2).Name & "=" & rstRecordSet.Fields(2) & " " & _
rstRecordSet.Fields(3).Name & "=" & rstRecordSet.Fields(3), vbOKCancel, "ÚÑÖ ÇáÚãáÇÁ")
rstRecordSet.MoveNext
Loop Until rstRecordSet.EOF = True
Select Case urmsg
Case 6 'If the user clicks "Yes" then...
rstRecordSet.MoveNext 'Quit the program
Case 7 'If the user click on No....
Exit Sub 'Then Exit the sub, not the program.
End Select
'With rstRecordSet
' .AddNew
' .Fields(0) = "New"
' .Fields(1) = "Record"
' .Update
'End With
'rstRecordSet.MoveFirst
'rstRecordSet.Delete
'rstRecordSet.Update
'rstRecordSet.Close
Else
MsgBox "Nn records were returned ushng the query " & cmdCommand.CommandText
End If
conConnection.Close
Set conConnection = Nothing
Set cmdCommand = Nothing
Set rstRecordSet = Nothing
End Sub
![]() |
Similar Threads
- how to print out an array in a message box (Java)
- I need the Mac OS X message box function (C)
- message box (ASP.NET)
- Time Release Message Box (C)
- download message box's events (ASP)
- repeating the whole program after pressing Yes button in the confirmation message box (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How to read MS-Access database tables?
- Next Thread: Qbasic Program
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






