'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 ImageView5 As ImageView
'Private ImageView6 As ImageView
'Private ImageView7 As ImageView
'Public ImageView8 As ImageView
'Public QRT2 As Byte
End Sub
Sub quartet2 (ImageView8 As ImageView, QRT2 As Byte)
Sub btnt_Click
'quartet2
Modul_LEDS.quartet2(QRT2)
End Sub
Ceci n'existe pas dans B4A.progrled.b4a étant le fichier principal contiendrait par exemple les #<includes> vers les fichiers progr_ram.b4a et progr_relais.b4a.
'Class Person module
Sub Class_Globals
Private FirstName, LastName As String
Private BirthDate As Long
End Sub
Sub Initialize (aFirstName As String, aLastName As String, aBirthDate As Long)
FirstName = aFirstName
LastName = aLastName
BirthDate = aBirthDate
End Sub
Public Sub GetName As String
Return FirstName & " " & LastName
End Sub
Public Sub GetCurrentAge As Int
Return GetAgeAt(DateTime.Now)
End Sub
Public Sub GetAgeAt(Date As Long) As Int
Private diff As Long
diff = Date - BirthDate
Return Floor(diff / DateTime.TicksPerDay / 365)
End Sub
Main module.
Sub Activity_Create(FirstTime As Boolean)
Private p As Person
p.Initialize("John", "Doe", DateTime.DateParse("05/12/1970"))
Log(p.GetCurrentAge)
End Sub
Sub Class_Globals
End Sub
'Sub Process_Globals
' 'These global variables will be declared once when the application starts.
' 'These variables can be accessed from all modules.
'End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
Sub quartet2 (qrt2 As Byte)
Dim led5,led6,led7,led8 As ImageView
If qrt2 = 0 Then
'******************************** 0 *************************************
led5.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
End Sub
Sub btunit_Click (Deco As decodleds)
Deco.quartet2(QRT2)
End Sub
#Region Project Attributes
#ApplicationLabel: nixie counter
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
'Activity module
Sub Process_Globals
Public QRT1 As Byte
' Public QRT2 As Byte
Public BV1 As Byte
Public BV2 As Byte
End Sub
Sub Globals
Private pnl1 As Panel
Private cvsGraph As Canvas
Private Label1 As Label
Private ImageView1 As ImageView
Private ImageView2 As ImageView
Private ImageView3 As ImageView
Private ImageView4 As ImageView
Private Lbll6 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main") ' load the layout
cvsGraph.Initialize(pnl1) ' initialize the Canvas for the panel
Dim Deco As decodleds
Deco.initialize(0)
pnl1.Invalidate
'set zeros
End Sub
Sub quartet1
If QRT1 = 3 Then
'******************************** 0 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
If QRT1 = 1 Then
'******************************** 1 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
If QRT1 = 2 Then
'******************************** 2 *************************************
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView2.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
ImageView3.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
ImageView4.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
End If
End Sub
Sub btunit_Click (Deco As decodleds) As Byte
BV1 = BV1 + 1
QRT1=Bit.And(0x0F,BV1)
quartet1
BV2 = BV1/16
qrt2 = Bit.And(0x0F, BV2)
Deco.quartet2(qrt2)
' Deco.quartet2(QRT2)
' D.initialise (QRT2)
Lbll6.Text = BV1
Label1.Text = "+++"
End Sub
Sub btdiz_Click
BV1 = 0
QRT1 = 0
' QRT2 = 0
quartet1
Lbll6.Text = BV1
Label1.Text = "ZZERO"
End Sub
Sub btcent_Click
BV1 = BV1 - 1
QRT1=Bit.And(0x0F,BV1)
quartet1
BV2 = BV1/16
' QRT2 = Bit.And(0x0F, BV2)
Label1.Text = "---"
If BV1 > 15 Then
Label1.Text = "33ces"
End If
Lbll6.Text = BV1
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Class_Globals
End Sub
'Sub Process_Globals
' 'These global variables will be declared once when the application starts.
' 'These variables can be accessed from all modules.
'
' Public QRT2 As Byte
'
'
'End Sub
'Initializes the object. You can add parameters To this method If needed.
Public Sub Initialize(qrt2 As Byte)
qrt2 = 0
End Sub
public Sub quartet2(qrt2 As Byte)
'Dim ImageWiew1, ImageWiev2, ImageWiev3, ImageWiev4)
Dim led5,led6,led7,led8 As ImageView
If qrt2 = 0 Then
'******************************** 0 *************************************
led5.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
If qrt2 = 2 Then
'******************************** 0 *************************************
led5.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
End If
If qrt2 = 4 Then
'******************************** 0 *************************************
led5.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
End If
End Sub
J'ai vu que tu as posé la même question dans le forum anglais.
Je n'ai pas répondu avant car j'avais des visites.
Préfères-tu continuer dans le forum français ou dans le forum anglais ?
Il y a plusieurs possibilités, mais il faudrait connaître plus en détail ce que tu veux faire dans la class.
Tu dois transmettre les ImageViews à la class pour qu'elles y soient accessibles.
Tu ne veux vraiment pas poster ton programme test ?
Sub Class_Globals
Private led5,led6,led7,led8 As ImageView
'Private qrt2 As Byte
End Sub
'Sub Process_Globals
' 'These global variables will be declared once when the application starts.
' 'These variables can be accessed from all modules.
'
' Public QRT2 As Byte
'
'
'End Sub
'Initializes the object. You can add parameters To this method If needed.
Sub Initialize(qrt2 As Byte, led5,led6,led7,led8 As BitmapDrawable)
qrt2 = 0
led5.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End Sub
public Sub quartet2 (qrt2 As Byte)
'Dim ImageWiew1, ImageWiev2, ImageWiev3, ImageWiev4)
'Dim led5,led6,led7,led8 As ImageView
If qrt2 = 0 Then
'******************************** 0 *************************************
led5.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
End If
If qrt2 = 2 Then
'******************************** 0 *************************************
led5.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
End If
If qrt2 = 4 Then
'******************************** 0 *************************************
led5.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led6.Bitmap = LoadBitmap(File.DirAssets, "led_vert.png")
led7.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
led8.Bitmap = LoadBitmap(File.DirAssets, "led_off.png")
End If
End Sub
#Region Project Attributes
#ApplicationLabel: nixie counter
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
'Activity module
Sub Process_Globals
' Public QRT2 As Byte
Public BV2 As Byte
Public qqr As Byte
End Sub
Sub Globals
Private pnl1 As Panel
Private cvsGraph As Canvas
Private Label1 As Label
Private Lbll6 As Label
Public Deco As decodleds
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main") ' load the layout
cvsGraph.Initialize(pnl1) ' initialize the Canvas for the panel
' Deco As decodleds
'Deco.initialize(0, 0)
pnl1.Invalidate
'set zeros
End Sub
Sub btunit_Click
' Dim Deco As decodleds
BV2 = BV2/16
qrt2 = Bit.And(0xFF, BV2)
Deco.quartet2(qrt2)
Lbll6.Text = BV2
Label1.Text = "+++"
End Sub
Sub btdiz_Click
BV2 = 0
' QRT2 = 0
Lbll6.Text = BV2
Label1.Text = "ZZERO"
End Sub
Sub btcent_Click
' QRT2 = Bit.And(0x0F, BV2)
Label1.Text = "---"
If BV2 > 15 Then
Label1.Text = "33ces"
End If
Lbll6.Text = BV2
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Pour moi, pour aider, je demande presque toujours de voir le projet.car je pensais qu'en vous envoyant les 2 sources (la classe + le main) cela suffirait.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?