Results 1 to 12 of 12

Thread: [RESOLVED] Implicit conversion - is it an Error ?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Resolved [RESOLVED] Implicit conversion - is it an Error ?

    I am using a standard messagebox but have an error that says
    “Implicit conversion from ‘Integer’ to ‘Microsoft.VisualBasic.MsgBoxStyle’ and when I go to the error by double clicking on the error message then ‘vbCritical+vbOKonly’ is highlighted.

    What’s that all about and what should I do about it if anything

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Implicit conversion - is it an Error ?

    Show your code...

    I just ripped this out of a small ppc app we have...

    Code:
    Select Case MessageBox.Show("Do you really want" _
                    & Microsoft.VisualBasic.ControlChars.NewLine _
                    & "to re-sync?", "Re-sync" _
                    , MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
        Case Windows.Forms.DialogResult.No
            Exit Sub
    End Select

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: Implicit conversion - is it an Error ?

    Here it is with the text shortened

    Code:
    MsgBox("WARNING!" & vbCrLf & "You ………" & vbCrLf & "Also…….." & vbCrLf & "THIS……" & "" & vbCrLf & "Your….", vbCritical + vbOKOnly, "Copy……")


  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Implicit conversion - is it an Error ?

    Quote Originally Posted by JohnSavage
    Here it is with the text shortened

    Code:
    MsgBox("WARNING!" & vbCrLf & "You ………" & vbCrLf & "Also…….." & vbCrLf & "THIS……" & "" & vbCrLf & "Your….", vbCritical + vbOKOnly, "Copy……")

    Why are you using the old MSGBOX function?

    Try switching to the true .Net function. Maybe the CF doesn't like MSGBOX (although I could not find that to be indicated in the help file)

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5
    ex-Administrator brad jones's Avatar
    Join Date
    Nov 2002
    Location
    Indianapolis
    Posts
    6,614

    Re: Implicit conversion - is it an Error ?

    Quote Originally Posted by JohnSavage
    Here it is with the text shortened

    Code:
    MsgBox("WARNING!" & vbCrLf & "You ………" & vbCrLf & "Also…….." & vbCrLf & "THIS……" & "" & vbCrLf & "Your….", vbCritical + vbOKOnly, "Copy……")
    I copy and pasted your code to a button event in a Pocket PC application for Visual Studio 2005. It compiled and ran fine in the Pocket PC 2003 emulator.

    I agree that using the .NET Framework MessageBox class makes more sense.

    Brad!
    Have you given out your reputation points today? Select the Rate This Post link to give points for good posts!
    -------------------------------------------------------------
    Brad! Jones
    Lots of Software, LLC
    (I wrote: C Programming in One Hour a Day) (Dad Jokes Book) (Follow me on Twitter)

    --------------------------------------------------------------

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Implicit conversion - is it an Error ?

    That error arose because you were using the addition operator "+", so the result was an Integer. You should have been using the bitwise Or operator so the result was still a MsgBoxResult value. That said, I'll throw my weight behind the suggestion that you use MessageBox.Show and avoid Runtime functions where possible.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: Implicit conversion - is it an Error ?

    Thanks Gents!

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: [RESOLVED] Implicit conversion - is it an Error ?

    I have used this which is a .Net example but

    MessageBox.Show("Typical installation is strongly recommended.", "Install information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

    I get the error
    “Overload resolution fails because no accessible ‘Show’ accepts this number of arguments”

    Why?

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] Implicit conversion - is it an Error ?

    Do you need the fifth argument that I have?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  10. #10
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: [RESOLVED] Implicit conversion - is it an Error ?

    The MessageBox function in the CF has been restricted down to just two of the several overloads available in the full version. You DO need the fifth argument, or you need to get rid of a few.
    My usual boring signature: Nothing

  11. #11
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] Implicit conversion - is it an Error ?

    That's what I thought...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: [RESOLVED] Implicit conversion - is it an Error ?

    Many thanks AGAIN !!

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