How to convert Visual C++ to VB

Can anyone convert this over to vb this is converted in Visual C++
unsigned char ucByte;
	int nCount;
	BOOL bHave_start_char = FALSE;
	DWORD dwStart_time = GetTickCount ();
	while (GetTickCount () - dwStart_time < 500) {
		while (m_pRS232->RXCount () > 0) {
			m_pRS232->Read_Buffer ((char*) &ucByte, 1);
//			#ifdef _DEBUG
//				Debug__Send_Byte_to_Output_Wnd (ucByte);
//			#endif
			if (bHave_start_char == FALSE) {
				if (ucByte == '~') {													//  TRUE = Have the start character
					bHave_start_char = TRUE;
					nCount = 1;
			switch (nCount) {
				case 1: if (ucByte != (unsigned char) '\x00') break; nCount++; continue;			//  Number of bytes, MSB
				case 2: if (ucByte != (unsigned char) '\x03') break; nCount++; continue;			//  Number of bytes, LSB
				case 3: if (ucByte != (unsigned char) '\x89') break; nCount++; continue;			//  API Identifier TxD status
				case 4: if (ucByte != (unsigned char)    'm') break; nCount++; continue;			//  Frame ID
				case 5: if (ucByte != (unsigned char) '\x00') break; nCount++; return TRUE;		//  Status byte, '\x00' = Successful
			bHave_start_char = FALSE;
	return FALSE;

Open in new window

Who is Participating?
DhaestConnect With a Mentor Commented:
I think that it will be easier to see what the function should do and rewrite it...
cmdolcetAuthor Commented:
Ok i can do that, however I can't copy the visual C++ code and run it in vb can I?
Nno you cannot do that and i am doing the translation for you.   But the best is to do as Dhaest say, identify the function input and ouptut.  Because in the bribe of code you submitted there is a rs232 port mentionned there which is not declare in this code portion.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.