This article is about errors in the Microsoft Small Basic program language.  If you know other errors, please add them to this article.


Syntax Errors

When you push [Run] button, two processes are started.  The first is compilation.  The Small Basic Environment (SB.exe) calls compiler (SmallBasicCompiler.exe) to compile Small Basic source code to msil for the .NET Framework.  The second process is to run that compiled code.  The Small Basic Environment calls the generated binary.

At compilation time, the compiler checks the syntax of the source code.  If there are any errors in it, the Small Basic Environment shows syntax errors.  Following message is a sample of a syntax error.  "1, 1:" means the number of line (row) and column of the error in the source code.

Sorry, we found some errors…
1,1: Subroutine 'Foo' is not defined.

These kind of syntax errors are listed on bottom in the active editor.  If you click a line of error messages, the cursor will be moved to the line of the source code.

The variable 'xxx' is used, but its value is not assigned.

This error occurs if some variable is not initialized in the code at all.  Following articles describes about one of a case of this errors.
Small Basic Known Issue: 26720 - Event Subroutines Should Be After They Are Registered

Syntax Error Message

The variable 'xxx' is used, but its value is not assigned.  Are you sure you have spelled it correctly?

Sample Code

Following code occurs this error.

a = b
TextWindow.WriteLine("a=" + a)

But following code doesn't occur this error.

a = b
TextWindow.WriteLine("a=" + a)
b = a
TextWindow.WriteLine("b=" + b)

Access is denied.

This error occurs when one of the programs in Small Basic\Samples folder is attempt to be run.

Syntax Error Message

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

The file cannot be accessed by the system.

This error occurs when the exe or SmallBasicLibrary.dll in current folder are available only online of your OneDrive. (This error was happened with old OneDrive.)

Syntax Error Message

The file cannot be accessed by the system. (Exception from HRESULT: 0x80070780)

N unexpected at this location.

This error occurs if a number is located the top of a line.

Syntax Error Message

N unexpected at this location.

Sample Code

3 + y = x

Operation 'Xxx.Xxx' is supplied N arguments, but takes M arguments.

If a number of arguments (parameters) of an operation is different, following error will occur.

Syntax Error Message

Operation 'Xxx.Xxx' is supplied N arguments, but takes M arguments.

Sample Code

TextWindow.Write("Number (0-15)? ")
decimal = TextWindow.ReadNumber()
txt = "0123456789ABCDEF"
subtxt = Text.GetSubText(txt, number + 1)
TextWindow.WriteLine(subtxt)

TextWindow.WriteLine("Hello, " name)

Cannot find operation 'Opxxx' in 'Objxxx'.

This error occurs when the operation Opxxx is not included in an object Objxxx. 

Syntax Error Message

Cannot find operation 'Opxxx' in 'Objxxx'.

Sample Code

Text.WriteLine("Hello World!")

Cannot find property 'Prxxx' in 'Objxxx'.

This error occurs when the property Prxxx is not included in an object Objxxx. 

Syntax Error Message

Cannot find property 'Prxxx' in 'Objxxx'.

Sample Code

Timer.Tick = Shapes.Move(invador[1], inx[1], iny[1])

Subroutine 'Xxx' is not defined.

If called subroutine is not defined, this error will occur.

Syntax Error Message

Subroutine 'Xxx' is not defined.

Sample Code

Foo()
Sub Bar
  TextWindow.WriteLine("Bar")
EndSub

The operation 'Objxxx.Opxxx' is expected a return value.

This error occurs when the operation written in right-hand side of assignment statement doesn't have return value. 

Syntax Error Message

The operation 'Objxxx.Opxxx' is expected a return value, but it doesn't return anything.

Sample Code

Timer.Tick Shapes.Move(invador[1]inx[1]iny[1])

Unexpected token Xxx found.

This error occurs if there is a keyword in an illegal place.

Syntax Error Message

Unexpected token Xxx found.

Sample Code

While c = " " Then

Unrecognized statement encountered.

This error occurs if a line has wrong syntax.

Syntax Error Message

Unrecognized statement encountered.

Sample Code

x + y = x

Run Time Errors

At running time, if there happens a trouble in Small Basic library, .NET Framework or Windows system, error popup will be displayed like below.  In the text box, there is a stack trace.  This includes names of subroutines which are called.

After an error popup, you may see following popup which shows the program has stopped working.

If you have installed Visual Studio, you will see "Debug the program" as follows.

You can see the problem details by pushing [v] button beside "View problem details".

Attempted to divide by zero.

Divided by zero causes this error from Small Basic 1.2.

Exception has been thrown by the target of an invocation.

Following actions cause this error.

  • GraphicsWindow.FillRectangle(0, 0, -1, -1)
  • Shapes.AddText() at the program top (Fixed for Small Basic v1.2)
  • GraphicsWindow.GetPixel(x, y) while x < 0 (Fixed for Small Basic v1.2)

Length cannot be less than zero.

If the length in Text.GetSubText(text, start, length) is less than zero, following error will occurs.

Sample Code

txt = "abcdefghijklmnopqrstuvwxyz"
start = 1
length = -1
subtxt = Text.GetSubText(txt, start, length)
TextWindow.WriteLine(subtxt)

'maxValue' must be greater than zero.

If the maxValue in Math.GetRandomNumber(maxValue) is less than zero, following error will occurs.

Specified cast is not valid.

Shapes.GetOpacity() causes following error.  Detail of this error is described in a TechNet article Small Basic Known Issue: 24406 - Shapes.GetOpacity() Causes Cast Error.

The request is not supported.

Following code causes this error in Windows 8.1. (Fixed for Small Basic v1.2)

TextWindow.WriteLine("Here")
TextWindow.Hide()
TextWindow.Show()

Value was either too large or too small for a Decimal.

If a value of a variable is larger than 79228162514264337593543950335 (2^96-1) or smaller than -79228162514264337593543950335 (-2^96+1) then following error occurs.  Also Math.Remainder(x, 0) causes this error.

Sample Code

num = 1
While "True"
  GraphicsWindow.Title = num
  num = num * 10
EndWhile

Value was either too large or too small for an Int32.

An internal type Int32 allows from -2147483648 (-2^31) to 2147483647 (2^31-1) .  If the parameter of Math.GetRandomNumber() operation is out of the latter range, following error occurs.

Other Errors

Microsoft Visual Basic was not found on your machine.

If Visual Basic is not installed this error occurs at graduate.  Visual Basic is included in Visual Studio 2013.  If only Visual Studio 2015 is installed, the same error occurs.  The link in this message is old.  See here for the new URL.


See Also

Other Languages