Solved

How to convert Visual C++ to VB

Posted on 2009-07-06
3
362 Views
Last Modified: 2013-11-26
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;
				}
	
				continue;
			}
	
			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

0
Comment
Question by:cmdolcet
3 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 24791797
I think that it will be easier to see what the function should do and rewrite it...
0
 

Author Comment

by:cmdolcet
ID: 24794955
Ok i can do that, however I can't copy the visual C++ code and run it in vb can I?
0
 
LVL 2

Expert Comment

by:TheBrainArts
ID: 24795643
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now