|
-
Oct 8th, 2006, 09:30 AM
#1
Thread Starter
Fanatic Member
c to vb convertion
need help in converting code from c to vb6
c code
unsigned char tabla1[] = {
0xB1, 0xB1, 0x73, 0x73, 0xE6, 0xE6,
0x5A, 0x5A, 0xAB, 0xAB, 0x47, 0x47,
0x8E, 0x8E, 0x0D, 0x0D, 0x1A, 0x1A,
0x34, 0x34, 0x68, 0x68, 0x0B, 0x0B
};
unsigned char tabla2[] = {
0x34, 0x62, 0x58, 0x92, 0x76, 0x13,
0x25, 0x97, 0x56, 0x28, 0x68, 0x13
};
then i convert into vb6
VB Code:
Dim table1 As Variant
Dim table2 As Variant
table1 = Array(&HB1, &HB1, &H73, &H73, &HE6, &HE6, _
&H5A, &H5A, &HAB, &HAB, &H47, &H47, _
&H8E, &H8E, &HD, &HD, &H1A, &H1A, _
&H34, &H34, &H68, &H68, &HB, &HB)
table2 = Array(&H34, &H62, &H58, &H92, &H76, &H13, _
&H25, &H97, &H56, &H28, &H68, &H13)
how about this?
unsigned short gethalf(unsigned char *donde)
{
return ((donde[1]<<8)|donde[0]);
}
void sethalf(unsigned char *donde, unsigned short que)
{
donde[0] = que & 0xFF;
donde[1] = (que>>8) & 0xFF;
}
void inv(unsigned char *cadena)
{
int i;
unsigned char temp;
for(i=0; i<=10; i+=2)
{
temp = cadena[i];
cadena[i] = cadena[i+1];
cadena[i+1] = temp;
}
}
-
Oct 8th, 2006, 09:45 AM
#2
Hyperactive Member
Re: c to vb convertion
I'm just writing this as I go, so it will probably have a few Bugs in it.
VB Code:
Public Function gethalf(donde As String) As Integer
gethalf = Chr(Asc(Mid(donde, 2, 1)) * (2 ^ 8) Or Mid(donde, 1, 1))
End Function
Public Function sethalf(donde As String, que As Integer)
Mid(donde, 1, 1) = que And &HFF
Mid(donde, 2, 1) = (que / (2 ^ 8)) And &HFF
End Function
Public Function inv(cadena As String)
Dim i As Integer
Dim temp As String
For i = 0 To 10 Step 2
temp = Mid(cadena, i, 1)
Mid(candena, i, 1) = Mid(cadena, i + 1, 1)
Mid(cadena, i + 1, 1) = temp
Next
End Function
-
Oct 8th, 2006, 09:54 AM
#3
Thread Starter
Fanatic Member
Re: c to vb convertion
cool 
how about this? mix with assembly? i need only some idea so i can do it my self. thanks
unsigned int calculo4a(unsigned int param0)
{
unsigned int r0, r1, r2;
int i;
r1 = unk;
r0 = param0 << 0x10;
r2 = r0 >> 0x10;
for(i=0; i<=0xf; i++)
{
r1 = r1 << 1;
r0 = r2;
r0 &= 1;
r1 |= r0;
r2 = r2 >> 1;
}
r0 = r1;
return r0;
}
-
Oct 8th, 2006, 10:23 AM
#4
Re: c to vb convertion
It's a function that returns unsigned int... i think that it can be done with Abs() in VB:
VB Code:
Private Function calculo4a (param0 As Integer) As Integer
Dim r0 As Integer, r1 As Integer, r2 As Integer
Dim i As Integer
'...
For i = 0 To 0xf Step 1
r1 = '...
Next i
'...
calculo4a = r0
End Function
-
Oct 8th, 2006, 10:47 PM
#5
Thread Starter
Fanatic Member
Re: c to vb convertion
by the way, gavio what the comment '... about? also here r1 = '...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|