obfuscate
Programmer
- Feb 8, 2010
- 29
I am using the following code, which works fine in VBA but not in VB...grrrrr
ClaimLines needs to be a number since mathmatical fucntions are performed based off its value or values < or > ClaimLines. I could stand to have it grabbed from extra as another data type as long as i can then convert that in to a true number
Say the number in that area of the screen is 32, well, the Excel VBA macro can get it and have it stored directly to ClaimLines (which is Dim'med as Integer). When I use a VB version of this macro I get the following error:
"Conversion from type '_ComObject' to type 'Integer' is not valid"
The Exception text is below:
I guess what im most confused about is why in Excel VBA it works fine but then in VB I have issues....once again, i can use and work in VBA at work but anything VB has to be done away from a system i can test on...any help would be greatly appreciated
ClaimLines needs to be a number since mathmatical fucntions are performed based off its value or values < or > ClaimLines. I could stand to have it grabbed from extra as another data type as long as i can then convert that in to a true number
Code:
Dim ClaimLines as Integer
ClaimLines = Sess0.Screen.Area(21, 8, 21, 9).Value
"Conversion from type '_ComObject' to type 'Integer' is not valid"
The Exception text is below:
Code:
************** Exception Text **************
System.InvalidCastException: Conversion from type '_ComObject' to type 'Integer' is not valid.
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value)
at HCFMacro.HCFMainForm.RunMacrobutton_Click(Object sender, EventArgs e)
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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
HCF Central Macro - for net 2
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/ab94883/Desktop/HCF%20Central%20Macro%20v2.01.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
I guess what im most confused about is why in Excel VBA it works fine but then in VB I have issues....once again, i can use and work in VBA at work but anything VB has to be done away from a system i can test on...any help would be greatly appreciated