Débutant : convertir un code C en VB.NET

alx3d Messages postés 2 Date d'inscription lundi 8 juillet 2002 Statut Membre Dernière intervention 2 mai 2006 - 19 janv. 2006 à 01:17
cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 - 19 janv. 2006 à 09:47
Bonjour à tous,

J'ai un code en C que j'aimerai traduire en VB.NET. Je n'ai aucune notion en C. Est-ce possible? Quelqu' un peut-il me donner un coup de main?

Code ---------------------------------

COMSTAT comstat;
DWORD dwErrorMask;
BYTE bytemp[64];
DWORD nToRead;
BOOL nRc;
DWORD ReturnedByteCount;
int i;

// anything to read, any errors?
ClearCommError(hVtrPort, &dwErrorMask, &comstat);
if(dwErrorMask)
return;

// make sure we don't read more
// than we have room for!
if(comstat.cbInQue > (DWORD) sizeof(bytemp))
nToRead = sizeof(bytemp);
else
nToRead = comstat.cbInQue;

// any?
if(nToRead == 0)
return;

// get the response
nRc = ReadFile(hVtrPort, (void *) bytemp,
nToRead, &ReturnedByteCount, NULL);

// sort out the return stuff...
if(nRc == FALSE)
return;

// NAK?if((*bytemp 0x011) && (*(bytemp + 1) 0x012))
// vtr doesn't like the command
// some error handling might be nice
return;

// ACK?if((*bytemp 0x010) && (*(bytemp + 1) 0x001))
// command ok, no return data
return;

#define SONY_DF 0x040

BYTE bymask[] = {0x03f, 0x07f, 0x07f, 0x03f};

// machine typeif((*bytemp 0x012) && (*(bytemp + 1) 0x011))
{
// process machine type
// this displays the return as xx yy
wsprintf(sztemp, "%2.2x %2.2x",
bytemp[2],
bytemp[3]);
SetDlgItemText(hWnd, IDC_MAIN_TIME, sztemp);
return;
}

// status/time code?
if((*bytemp & 0x0f0) == 0x070)
{
// status?
if(*(bytemp + 1) == 0x020)
{
// show the status
// in the real world, you'll have to decode
// the bits' what's of importance to you
// displays the first 4 bytes of returned data
wsprintf(sztemp, "%2.2x %2.2x %2.2x %2.2x ...",
bytemp[2],
bytemp[3],
bytemp[4],
bytemp[5]);
SetDlgItemText(hWnd, IDC_MAIN_TIME, sztemp);
return;
}
else
{
// bravo! maybe something useful
// some kind of time code...
// in our case, it can only be time
// this displays the time as 00:00:00:00 N
wsprintf(sztemp, "%2.2x:%2.2x:%2.2x:%2.2x %c",
(bytemp[5] & bymask[3]),
(bytemp[4] & bymask[2]),
(bytemp[3] & bymask[1]),
(bytemp[2] & bymask[0]),
(char)
(((bytemp[2] & SONY_DF) == 0)? 'N' : 'D'));
SetDlgItemText(hWnd, IDC_MAIN_TIME, sztemp);
}
}

Fin code-------------------------------------------------------------

1 réponse

cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 1
19 janv. 2006 à 09:47
Bonjour,

Fais une recherche sur google, y a des sites de conversion automatique de C vers VB.NET
0
Rejoignez-nous