Question Argument Exception is unhandled

Keith_McCloy

Member
Joined
Dec 13, 2011
Messages
6
Programming Experience
10+
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 a moderator:
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:)
 
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 ?
 
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
 
Back
Top