C++ into VB

Nov 14, 2013 at 2:44am
Hello,

I'm going to translate below logic into vb. I confuse what the logic trying to get. What is the relation between DevcName and the Reader_F., and what the [100] means.

Thanks!

1
2
3
4
5
6
7
8
	RdrName Reader_F[100];
	long l_ret_value = CBM_EnumerateReader(Reader_F);

	CHAR* DevcName;
	int idx;
	for(int i = 0; i< Reader_F->ul_NbRdr; i++)
	{
		DevcName = Reader_F[i].cRdrName;
Nov 14, 2013 at 3:43am
I myself am pretty new to C++, but I believe [100] is good indication that you're dealing with arrays. The for loop also points into that direction.
Nov 14, 2013 at 3:48am
Your code seems a little incomplete to me...are there other statements in the for loop cause your closing brace is missing.
Nov 14, 2013 at 4:06am
full code is like this. not understand the function in bold. is that array in Reader_F

RdrName Reader_F[100];
long l_ret_value = EnumerateReader(Reader_F);

CHAR* DevcName;
int idx;
for(int i = 0; i< Reader_F->ul_NbRdr; i++)
{
DevcName = Reader_F[i].cRdrName;
idx = m_RdrNameCBM.AddString(DevcName);
m_RdrNameCBM.SetItemDataPtr(idx,DevcName);
UpdateData(FALSE);
}
m_RdrNameCBM.SetCurSel(0);
Nov 14, 2013 at 8:58am
Reader_F is the array that can store 100 elements of the type RdrName

That's what EnumerateReader does: it stores a certain amount of objects (type RdrName) and returns in l_ret_value how many objects are stored.

CHAR* DevcName; -> DevcName is a variable that has the type CHAR*. It basically is a c string

types are important in C++. You can't have a variable without saying exactly what type it has

[EDIT]
Reader_F->ul_NbRdr may look confusing. It uses the fact that an array can be implicitly converted to a pointer to the first element. You can also write it like so Reader_F[0].ul_NbRdr
[/EDIT]
Last edited on Nov 14, 2013 at 9:04am
Topic archived. No new replies allowed.