hi
I want to make a custom message box alert just like VB6 built-in "VBOKCancel"....In that custom message box alert, i want the functionality of "VBOKCancel" as well as an additional button and check boxes.....much appreciated if anybody helps me out.

Thanx

Recommended Answers

All 8 Replies

Err... Why don't you just make a new form (frmMsgBox)?

You can just do something like:

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?

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:

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:

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:

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

Why use Active-X? Just define a form, it's straight forward and simple.

My ActiveX dll can be used by VBScript. That was my whole point in making it an ActiveX dll. Really, it can be called from most any language.

Since he hasn't been back since he posted this request, I guess it doesn't really matter how cool or how easy a method is. He's just wasted our time...

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 just want to customize regular messagebox sound, is that possible?

serkan sendur,

Please start your own thread

No. You will have to make your own form that looks like a message box.

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.