Home > Software engineering >  VB to convert hexadecimal
VB to convert hexadecimal

Time:09-20

 Sub kk () 

Dim B (0 To 15) As Byte
For I=0 To 15
B (I)="0"
Next
If CheckBox1. Checked=True (0)="1" Then B
If CheckBox2. Checked=True Then B (1)="1" 'new added
If CheckBox3. Checked=True Then B (2)="1"
If CheckBox4. Checked=True Then B (3)="1"
If CheckBox5. Checked=True Then B (4)="1"
If CheckBox6. Checked=True Then B (5)="1"
If CheckBox7. Checked=True Then B (6)="1"
If CheckBox8. Checked=True Then B (7)="1"
If CheckBox9. Checked=True Then B="1" (8)
If CheckBox10. Checked=True Then B (9)="1"
If CheckBox11. Checked=True Then B (10)="1"
If CheckBox12. Checked=True Then B (11)="1"
If CheckBox13. Checked=True Then B (12)="1"
If CheckBox14. Checked=True Then B (13)="1"
If CheckBox15. Checked=True Then B (14)="1"
If CheckBox16. Checked=True Then B (15)="1"
TextBox1. Text=""
A=0
C=0
D=0
For I=0 To 7
C=C + B (I)
Next
For I=8 To 15
D=D + B (I)
Next
For I=2 To 11.
A=A + B (I)


Consult everybody, I want to have A this variable into hexadecimal, how to do

CodePudding user response:

Hex (A)

CodePudding user response:

You end up there, "two to 11" is why? Only 10 bit in the middle of it?

 dim n as long 
N=1
For I=2 to 11.
A=A + n * B (I)
N=n + n
Next

With dozen of code, but there should be no problem,

CodePudding user response:

Msgbox hex (A)

CodePudding user response:

I only want 2 to 11

CodePudding user response:

Now that require A hexadecimal, I guess (I) should B A value, A calculation method is wrong (the first is the number of statistics in 1),
 'calculated on a value' 
For I=2 To 11.
A=A + B (I) * (2 ^ I)
Next
'displays hexadecimal'
MsgBox "& amp; H "& amp; Hex (A)

CodePudding user response:

I need to ridicule control array again.

If there are 1000 checkbox, the building code is very sexy.

CodePudding user response:

refer to 6th floor WallesCai response:
I need to ridicule control array again.

If there are 1000 checkbox, the building code is very sexy.

CodePudding user response:

refer to 6th floor WallesCai response:
I need to ridicule control array again.

If there are 1000 checkbox, the building code is very sexy.

Are you sure you have noticed:
The original poster is the application environment of VBA instead of VB6, under the VBA environment of window, cannot use the control array,

CodePudding user response:

The original poster is the VBA?

CodePudding user response:

This two days to use the Excel, found Excel the CheckBox "Checked" property,
Logo "choose" properties, with VB6 is the same, is still the Value attribute,
To estimate other VBA environment will also be the same,


Think the building Lord used may not be a VBA form, and it is possible that VB.NET...

So, this bottom can use the control array,

CodePudding user response:

Problem has been solved, VB.net
  • Related