Newbie here. I’m learning to use invoke code by following a tutorial. The very first simple code I wrote has errors already. I’m trying to simply show a message box with leap year. Here’s the code (in VB.net):
'FIND LEAP YEAR
Dim year As Integer
year = 2016
If year Mod 4 = 0 Then
MsgBox("This is a leap year")
Else
MsgBox("This is not a leap year")
End If
The error is:
Invoke Code: No compiled code to run
error BC30451: 'MsgBox' is not declared. It may be inaccessible due to its protection level. At line 15
error BC30451: 'MsgBox' is not declared. It may be inaccessible due to its protection level. At line 17
So, it seems it’s not recognizing MsgBox as a valid keyword. Is there another way? Is there an import I am missing? Is the keyword MsgBox not right? I’m learning so appreciate any explanation. The tutorial didn’t get this error so I’m confused. I seem to have the standard imports as listed here:
Dim year As Integer
year = 2016
If year Mod 4 = 0 Then
MsgBox("This is a leap year")
Else
MsgBox("This is not a leap year")
End If
same error:
`error BC30451: 'MsgBox' is not declared. It may be inaccessible due to its protection level. At line 6
`
I don’t understand why the tutorial guy had that code and no error, and also a respondent here tried my code and also had no error. Why am I having this error?
I stripped the code to barebones for testing and tried many variations. Finally, this works:
System.Windows.MessageBox.Show("hello")
I couldn’t get MsgBox to work on its own. I imported system.windows.forms and that didn’t work. MessageBox is “ambiguous” in a couple of imports, so the full namespace as in code above seems to be needed. This is my first foray into UiPath invoke code. I hope it’s not always this hard to get something so simple to work.