Question

In VB you can both define and assign a value to a variable in one line.

Can you do this in Basic4Android?

VB code sample:

Dim strMyVariable As String = "Some text is in here"

Update: I tried this and got the following error:

NumberOfColumns As Int = 5  ' Number of columns.

Compiling code.                         Error
Error compiling program.
Error description: '=' expected.
Occurred on line: 13
NumberOfColumns As Int = 5' Number of columns.
Word: numberofcolumns

Update:

Compiling code.                         Error
Error compiling program.
Error description: Syntax error.
Occurred on line: 13
Dim NumberOfColumns As Int = 5 ' Number of columns.
Word: int
Was it helpful?

Solution

AFAICT, you can't.

If you really feel you need to do it on the same line, you can do it like this:

Dim NumberOfColumns As Int: NumberOfColumns = 5

The colon is defined in the user's guide (page 111) as the "separator for two statements on the same line".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top