You are viewing our Forum Archives. To view or take place in current topics click here.
Im a noob... Error in Vb help?
Posted:
Im a noob... Error in Vb help?Posted:
Status: Offline
Joined: Jul 25, 201113Year Member
Posts: 728
Reputation Power: 42
Hey guys, i was wondering if anyone could spend two seconds helping me out.
I keep getting this error when concatenating.
Conversion from string " and is an integer" to type 'Integer' is not valid.
This is the relevant line...
MsgBox("The number is " & NumInt, " and " & IntCheckF)
Cheers in advance, Steven.
I keep getting this error when concatenating.
Conversion from string " and is an integer" to type 'Integer' is not valid.
This is the relevant line...
MsgBox("The number is " & NumInt, " and " & IntCheckF)
Cheers in advance, Steven.
#2. Posted:
Status: Offline
Joined: Aug 20, 201410Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 201410Year Member
Posts: 6,813
Reputation Power: 413
Are you sure that is the relevant line? I don't see the string " and is an integer" in that line of code. Could you show a larger section of code? Or a screenshot of the error dialog
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Jul 25, 201113Year Member
Posts: 728
Reputation Power: 42
Sure thing man!
Code in question: [ Register or Signin to view external links. ]
Im still learning but i can't think what is going wrong...
Code in question: [ Register or Signin to view external links. ]
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Conversion from string " and is an integer" to type 'Integer' is not valid.
Source=Microsoft.VisualBasic
StackTrace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
at Task1.Form1.ButtonFind_Click(Object sender, EventArgs e) in C:\Users\Steven\AppData\Local\Temporary Projects\Task1\Form1.Designer.vb:line 95
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Task1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.FormatException
HResult=-2146233033
Message=Input string was not in a correct format.
Source=Microsoft.VisualBasic
StackTrace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
InnerException:
Im still learning but i can't think what is going wrong...
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Aug 20, 201410Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 201410Year Member
Posts: 6,813
Reputation Power: 413
I think I see the error, in the line:
There is a comma after NumInt, I am guessing you accidentally put that there instead of an ampersand (&). The comma is splitting the code and the into two separate parameters of MsgBox(), instead of using them as one string.
Solution:
Replace the comma with the & operator
If you need any further help, PM me!
MsgBox("The number is " & NumInt, " and " & IntCheckF)
There is a comma after NumInt, I am guessing you accidentally put that there instead of an ampersand (&). The comma is splitting the code
"The number is " & NumInt
" and " & IntCheckF
Solution:
Replace the comma with the & operator
If you need any further help, PM me!
- 0useful
- 0not useful
#5. Posted:
Status: Offline
Joined: Jul 25, 201113Year Member
Posts: 728
Reputation Power: 42
Cheers a bunch, i haven't a clue why that was there. I sure will!
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.