Setting a Spinners index

Shane119

Member
Licensed User
Longtime User
Hi Everyone :sign0085:

I've been using VB6 and VBA for too long!!!!

Can anyone help me please, I can;t see what's wrong with the following code:

If rstConsultants.RowCount > 0 Then
For Counter = 0 To Consultant.Size -1
If Consultant.getitem(Counter) = rstConsultants.GetString("ConsultantName") Then
Consultant.SelectedIndex = Counter
End If
Next Counter
End If

I get the following error when compiling:

Compiling generated Java code. Error
B4A line: 95
Consultant.SelectedIndex=Counter
javac 1.6.0_23
src\SBS\co\uk\LegionellaSurveyor\configscreen.java:422: not a statement
_counter;
^
1 error

All I'm trying to do is after populating a spinner with the names of consultants, is set the selected item to the one that matches the one I'm looking for.

Thanks inadvance for your help
 
Hi Earl

Tried this and get a slightly different error:

Compiling code. 0.06
Generating R file. 0.00
Compiling generated Java code. Error
B4A line: 102
Consultant.SelectedIndex=Counter
javac 1.6.0_23
src\SBS\co\uk\LegionellaSurveyor\configscreen.java:432: not a statement
_counter;
^
1 error

i.e. 432 instead of 422.....
 
Upvote 0
I've commented line 102 out and get the following error:

Compiling generated Java code. Error
B4A line: 101
If Consultant.getitem(Counter) = rstConsultants.GetString(\
javac 1.6.0_23
src\SBS\co\uk\LegionellaSurveyor\configscreen.java:429: not a statement
_counter;
^
1 error

Line 101 is:
If Consultant.getitem(Counter) = rstConsultants.GetString("ConsultantName") Then


The Above variables/controls/views are:

I think it's a problem with the spinner Consultant.... Even if I change the contents of the for loop to:

If rstConsultants.RowCount > 0 Then
For Counter = 0 To Consultant.Size -1
Log(Consultant.GetItem(Counter))
Next Counter

I get the:

Compiling generated Java code. Error
B4A line: 102
Log(Consultant.GetItem(Counter))
javac 1.6.0_23
src\SBS\co\uk\LegionellaSurveyor\configscreen.java:432: not a statement
_counter;
^

oh hum.... maybe I've delared it in the wrong place, incorrect syntax... I'm a little stumped on this.
 
Upvote 0
It seems that you haven't removed the Counter variable from the Next line as Erel already told you.

Instead of
Code:
For Counter = 0 To Consultant.Size -1
  Log(Consultant.GetItem(Counter))
Next [COLOR=red]Counter[/COLOR]
you should use
Code:
For Counter = 0 To Consultant.Size -1
  Log(Consultant.GetItem(Counter))
Next
Best regards.
 
Upvote 0
Claus and Earl - my appologies I think I've had too much wine. Thank you again for your help - next time I will put my glasses on and read it properly. I've recompiled the code following your suggestion and it worked perfectly :)

Again thank you both for your help.
 
Upvote 0
Back
Top