Firstly, I am generating the integer value based on the checkboxes the user selects with the code below.
Private Sub chk_AltHold_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chk_AltHold1.CheckedChanged, chk_AltHold2.CheckedChanged, chk_AltHold3.CheckedChanged, chk_AltHold4.CheckedChanged, chk_AltHold5.CheckedChanged, chk_AltHold6.CheckedChanged, chk_AltHold7.CheckedChanged, chk_AltHold8.CheckedChanged
'Sc 3D Tx Setup
Dim alt_val As Integer = 0
Dim alt_valS As String
If (chk_AltHold1.Checked) Then alt_val = alt_val + 1
If (chk_AltHold2.Checked) Then alt_val = alt_val + 2
If (chk_AltHold3.Checked) Then alt_val = alt_val + 4
If (chk_AltHold4.Checked) Then alt_val = alt_val + 8
If (chk_AltHold5.Checked) Then alt_val = alt_val + 16
If (chk_AltHold6.Checked) Then alt_val = alt_val + 32
If (chk_AltHold7.Checked) Then alt_val = alt_val + 64
If (chk_AltHold8.Checked) Then alt_val = alt_val + 128
alt_valS = alt_val.ToString.PadLeft(4, "0"c)
txt_FnHtLock.Text = alt_valS
End Sub
This converts the checkboxes checked into an integer 0-255 thats represenatative of an 8 bit binary number.
I need to do it in reverse. Take the integer and convert to binary and check the boxes accordingly.
I have searched endlessly, ad tried several different things in code to achieve this to no avail.
I am used to microcontroller programming in various languages, and the equivalent is easy for that, but in VB.net, I cant figure it out.
Any help is very much appreciated.

New Topic/Question
This topic is locked



MultiQuote






|