How to call a Service sub with a parameter

prestondocks

Member
Licensed User
Longtime User
I have the following code in a service module

B4X:
sub setVolume(volume as Int)
   mp.SetVolume(10/volume,10/volume)
end sub

In my main module I have.

B4X:
Sub barVolume_ValueChanged (Value As Int, UserChanged As Boolean)
   
      CallSub(Radio,"setVolume(Value)")
      
End Sub

Obviously this is not going to work because Value can not be passed like this. So how do I pass the Value variable into the setVolume sub?
 

prestondocks

Member
Licensed User
Longtime User
I found the solution

As is the usual case, you post a question then immediately find the answer.

The Answer is CallSub2 of course.

B4X:
Sub barVolume_ValueChanged (Value As Int, UserChanged As Boolean)
   
      CallSub2(Radio,"setVolume",Value)
      
End Sub
 
Upvote 0
Top