Select case problem

EddyW

Member
Licensed User
Longtime User
hi All,

Think i make a simple mistake but i dont see what.
CboFlashmode is a spinner filled with 4 values (auto, on, off and torch) and depending on the value you select the camera will be set to that value.
But in the code below its goes always to the else statement even when the value is 1 of the 3 other values.

What do i wrong?

B4X:
Sub cboFlashMode_ItemClick (Position As Int, Value As Object)

   Dim sWaarde As String = cboFlashMode.SelectedItem.ToUpperCase

   Select sWaarde
   Case "ON"
      camera1.FlashOn
   Case "OFF"
      camera1.FlashOff
   Case "TORCH"
      camera1.FlashTorch
   Case Else
      camera1.FlashAuto
   End Select
   
End Sub
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
Replace this:
B4X:
Dim sWaarde As String = cboFlashMode.SelectedItem.ToUpperCase
With:
B4X:
Dim sWaarde As String = Value.ToUpperCase
 
Upvote 0

EddyW

Member
Licensed User
Longtime User
i did try that before but then get the error 'Unknown type: Object' when i compile. Think i have to convert Value to string first but didnt find the command for that yet.

I also tried with Sub cboFlashMode_ItemClick (Position As Int, Value As string) instead of Sub cboFlashMode_ItemClick (Position As Int, Value As Object)
then value.touppercase works but dont solve my problem.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
How did you populate the Spinner ?
You could also use:
B4X:
Sub cboFlashMode_ItemClick (Position As Int, Value As Object)

    Dim sWaarde As String = cboFlashMode.SelectedItem.ToUpperCase

    Select Position
    Case 0
        camera1.FlashOn
    Case 1
        camera1.FlashOff
    Case 2
        camera1.FlashTorch
    Case Else
        camera1.FlashAuto
    End Select
    
End Sub
Best regards.
 
Upvote 0

EddyW

Member
Licensed User
Longtime User
I polulate it with code below but the regex isnt good and i still have to look at it.
I use the AdvancedCamera lib.


B4X:
Dim lFlashModes As List = camera1.SupportedFlashMode
If lFlashModes.IsInitialized = False Then
   cboFlashMode.Add("<Flash not supported>")
   cboFlashMode.Enabled = False
Else
    ' fill spinner
   cboFlashMode.AddAll(Regex.Split("\,",lFlashModes))
End If
 
Upvote 0
Top