Results 1 to 3 of 3

Thread: [RESOLVED] MsgBoxStyle as Variable Type mismatch

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Resolved [RESOLVED] MsgBoxStyle as Variable Type mismatch

    Hi ,

    I wanna make MsgBoxStyle as Variable
    i have 4 option
    each one save
    vbCritical
    vbQuestion
    vbExclamation
    vbInformation

    i do code like this
    Code:
    Dim opvalue As String
    If Op1.value = True Then opvalue = "vbInformation"
    If Op2.value = True Then opvalue = "vbQuestion"
    If Op3.value = True Then opvalue = "vbCritical"
    If Op4.value = True Then opvalue = "vbExclamation"
    
    MsgBox "testing", vbOKOnly + opvalue, "test"
    it cause exception type mismatch
    what i'am doing wrong ?

    Thanks

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: MsgBoxStyle as Variable Type mismatch

    Value must be of an Integer type - not string.

    You can do something like this:
    Code:
    Option Explicit
    
    Private Enum myMsgStyle
        msgInformation = VBA.VbMsgBoxStyle.vbInformation
        msgQuestion = VBA.VbMsgBoxStyle.vbQuestion
        msgCritical = VBA.VbMsgBoxStyle.vbCritical
        msgExclamation = VBA.VbMsgBoxStyle.vbExclamation
    End Enum
    
    Private Sub Command1_Click()
    
    Dim opvalue As Integer
    
        If Op1.Value = True Then opvalue = myMsgStyle.msgInformation
        If Op2.Value = True Then opvalue = myMsgStyle.msgQuestion
        If Op3.Value = True Then opvalue = myMsgStyle.msgCritical
        If Op4.Value = True Then opvalue = myMsgStyle.msgExclamation
    
    End Sub
    or this
    Code:
    Private Sub Command1_Click()
    
    Dim opvalue As Integer
    
        If Op1.Value = True Then opvalue = VBA.VbMsgBoxStyle.vbInformation
        If Op2.Value = True Then opvalue = VBA.VbMsgBoxStyle.vbQuestion
        If Op3.Value = True Then opvalue = VBA.VbMsgBoxStyle.vbCritical
        If Op4.Value = True Then opvalue = VBA.VbMsgBoxStyle.vbExclamation
    
    End Sub

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: MsgBoxStyle as Variable Type mismatch

    Yes must be Integer not String

    Thanks m8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width