Convert C++ Code to Vb.net code

  • Thread starter Thread starter norton
  • Start date Start date
N

norton

Does anyone know how can i convert this C++ code into VB.Net code?'
(Soruce from: http://members.lycos.co.uk/happybcb/article/tips/cbc_12.htm)
i=0xa1??? not an integer and donno how to convert >_<

thx in advance!


//TURBO C++ 3.0
#include <Stdio.h>
#include <stdlib.h>
void main(){
FILE * codefile;
int i,j,k;
codefile=fopen("table.txt","w+b");
for (i=0xa1;i<=0xfe;I++){
for(j=0x00;j<=0xff;j++){
fwrite(& i,1,1,codefile);
fwrite(& j,1,1,codefile);}
}
fclose(codefile);
return;
}
 
If the For loops is the problem you are having, they are hex values and you
can code them as follows

For i = &HA1 To &HFE
For j = &H0 To &HFF
Next
Next

The file I/O could be done a number of ways

Regards

Shane
 
norton said:
Does anyone know how can i convert this C++ code into VB.Net code?'
(Soruce from: http://members.lycos.co.uk/happybcb/article/tips/cbc_12.htm)
i=0xa1??? not an integer and donno how to convert >_<

thx in advance!


//TURBO C++ 3.0
#include <Stdio.h>
#include <stdlib.h>
void main(){
FILE * codefile;
int i,j,k;
codefile=fopen("table.txt","w+b");
for (i=0xa1;i<=0xfe;I++){
for(j=0x00;j<=0xff;j++){
fwrite(& i,1,1,codefile);
fwrite(& j,1,1,codefile);}
}
fclose(codefile);
return;
}

sub Main()

Dim fs As New System.io.FileStream("table.txt", IO.FileMode.Open,
IO.FileAccess.Write)
For i As Byte = &HA1 To &HFE
For j As Byte = &H0 To &HFF
fs.WriteByte(i)
fs.WriteByte(j)
Next
Next
fs.Close()

end sub;
 
I have fixed the overflow problem...wanna to say a BIG THANKS to all of you
..
Here is the code

Dim fs As New System.io.FileStream("table.txt", IO.FileMode.Open,
IO.FileAccess.Write)
Dim i, j As Byte
For i = &HA1 To &HFE
For j = &H0 To &HFE
fs.WriteByte(i)
fs.WriteByte(j)
Next
Next
fs.Close()
 
Back
Top