Results 1 to 4 of 4

Thread: Argument Exception is unhandled

  1. #1
    Keith_McCloy is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.0
    Join Date
    Dec 2011
    Posts
    5
    Reputation
    0

    Argument Exception is unhandled

    I have the following code in my program;-

    Do
    astring = "Interpolated at Level " & CStr(level) & ". Continue (C), Save and Continue (S) or Stop (X)?"
    bstring = "Refine the interpolation or not?"
    cstring = "C"
    cstring = InputBox(astring, bstring, cstring).ToUpper
    Select Case cstring
    Case "C"
    buildstatus = True
    Case "S"
    Call AllOfTheDataToolStripMenuItem1_Click(sender, e)
    buildstatus = True
    Case "X"
    buildstatus = False
    End Select
    Loop While ((cstring <> "C") And (cstring <> "S") And (cstring <> "X"))

    I get the error given in the title at the InputBox() line, telling me that a parameter is not valid. I have tried changing this to a MsgBox Function (with minor code changes) and get the same error. I do not think the problem is in this line of code, but where is the problem? Any help will be appreciated.
    Last edited by jmcilhinney; 04-17-2012 at 6:04 AM. Reason: Added [xcode=vb.net] tags for readability

  2. #2
    hipturtle's Avatar
    hipturtle is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 3.5
    Join Date
    Dec 2011
    Posts
    59
    Reputation
    22
    Quote Originally Posted by Keith_McCloy View Post
    I have the following code in my program;-

    Do
    astring = "Interpolated at Level " & CStr(level) & ". Continue (C), Save and Continue (S) or Stop (X)?"
    bstring = "Refine the interpolation or not?"
    cstring = "C"
    cstring = InputBox(astring, bstring, cstring).ToUpper
    Select Case cstring
    Case "C"
    buildstatus = True
    Case "S"
    Call AllOfTheDataToolStripMenuItem1_Click(sender, e)
    buildstatus = True
    Case "X"
    buildstatus = False
    End Select
    Loop While ((cstring <> "C") And (cstring <> "S") And (cstring <> "X"))

    I get the error given in the title at the InputBox() line, telling me that a parameter is not valid. I have tried changing this to a MsgBox Function (with minor code changes) and get the same error. I do not think the problem is in this line of code, but where is the problem? Any help will be appreciated.
    Hello I am not sure why you are getting this error, but I loaded this code into VB.Net 2010 and everything seemed to work ok. Obviously I had to make some changes as I did not know where buildstatus or level came from. As you can see I took the astring, bstring and cstring out of the loop and made sure they were set as variables using dim. I don't know which version of the language you are using but my VB would not let me have this code as you have it.


    Dim buildstatus as Boolean = True
    Dim level as Integer = 0
    Dim astring as String = "Interpolated at Level " & CStr(level) & ". Continue (C), Save and Continue (S) or Stop (X)?"
    Dim bstring as String = "Refine the interpolation or not?"
    Dim cstring as String = "C"


    I also added the Do Loop code for the rest of it and it ran perfectly.

    Hope this is of some help

  3. #3
    SLPx is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Apr 2012
    Location
    Sri Lanka
    Posts
    17
    Reputation
    16
    Even though cStr() should provide the necessary info,
    Try
    "Interpolated at Level "+ level.tostring + ". Continue (C), Save and Continue (S) or Stop (X)?"

    Your code is OK, What version is your VB and .Net Framework ?

  4. #4
    Keith_McCloy is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.0
    Join Date
    Dec 2011
    Posts
    5
    Reputation
    0
    Thanks hipturtle and SLPx for your comments. I am using Visual Basic Express Edition 2008. I have myself taken this segment of code and used it to make a new application and it runs fine, hence my query.


    So, I can only deduce that the problem is elsewhere. Is it possible that I am clobering something? I do not think that I am running out of memory as the Project exe file is 142 KB and I have 2 gigabytes of RAM in the machine.


    I appreciate the help given.


    Keith

Bookmarks

Posting Permissions

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