How can we give you advice or examples if you don't indicate what exactly you want to program anyway?My source code will get long and take several pages to write and it will be difficult to manage with a single page.
How can I simply fix this problem ?
If QRT1 = 4 Then
'******************************** 1 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
End If
If QRT1 = 5 Then
'******************************** 2 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
If QRT1 = 6 Then
'******************************** 2 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
End If
If QRT1 = 7 Then
'******************************** 0 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
It may not be necessary to write all the "imageview.bitmap=" lines.How can we give you advice or examples if you don't indicate what exactly you want to program anyway?
For Each iv As view In panelImageView.GetAllViewsRecursive
if iv as imageview then
'your code here
end if
Next
As you've been told: classesMy source code will get long and take several pages to write and it will be difficult to manage with a single page.
How can I simply fix this problem ?
Where can i find an example ?
If QRT1 = 4 or QRT1 = 5 OR .... Then (or even if QRT1 >= 4 AND QRT1 <= 8)
'******************************** 2 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
private codem as mycodeclass
codem.initilize
select QTR1
case 4
codem.setButtons(false,true,false,false)
case 5
codem.setButtons(false,true,false,true)
end Select
... In the class mycodeclass
private sub setButtons(img1show as boolean, img2show as boolean, img3 as boolean, img4as boolean)
iif(img1show,setImage(imageView1,"led_off.png"),setImage(imageView1,"led_vert.png"))
iif(img2show,setImage(imageView2,"led_off.png"),setImage(imageView2,"led_vert.png"))
iif(img3show,setImage(imageView3,"led_off.png"),setImage(imageView3,"led_vert.png"))
iif(img4show,setImage(imageView4,"led_off.png"),setImage(imageView4,"led_vert.png"))
end sub
private sub setImage(imgv as imageview, img as string)
imgv.bitmap = LoadBitmap(File.dirAssets,img)
end sub
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Private xui2 As XUI
Public toto As Byte
Public var As Byte
Public result As Byte
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
var = 1
result = modulM.calctoto(1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
xui2.MsgboxAsync ("result", "B4X" )
End Sub
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'Public toto As Byte
End Sub
Public Sub calctoto(var As Byte)
Dim toto As Byte
toto = toto + var
Return toto
End Sub