Solved

How to convert Visual C++ to VB

Posted on 2009-07-06
3
352 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
Comment Utility
I think that it will be easier to see what the function should do and rewrite it...
0
 

Author Comment

by:cmdolcet
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

10 Experts available now in Live!

Get 1:1 Help Now