Web Development

General discussion


C++Builder5 Input field

By cvanlumig ·
I want to create a form with an input-field.
In this field the user can enter an address
an a data byte. My question is how to read
the data from the input-field and send it
to my development kit(EZ-USB FX). Below you'll find
a part of my program:

void __fastcall TForm1::Button5Click(TObject *Sender)
UCHAR outBuffer[64];
WORD outPacketSize;
UCHAR inBuffer[64];
WORD inPacketSize;
unsigned long nBytes = 0;
int i;
char read;
BOOL success;
char str[10];
bulkControl.pipeNum = 1;
outPacketSize = 64;
// Clear Buffer
for(i = 0; i < 63 ; i++)
outBuffer = 0;
outBuffer[0] = data; // This needs to be the inputdata
success = DeviceIoControl (handle,
if(success == TRUE)
sprintf (str, "Write succeeded: 0x%02X nbytes: 0x%02X", outBuffer[20], nBytes);

If it isn't clear what I want to do, please ask

kind regards,

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Hope this helps

by Jeremy6 In reply to C++Builder5 Input field

What kind of control are you using to get the data from the user? I also assume, from what you have here, that you are limiting the number of characters the user can enter to 63 since that is the length of your buffer.
Depending on which control you are using there could be a Text property or a Caption property that will give you access to the text, or you may have to do something like you are with the Memo and scroll through the lines in the control. So we really need to know what control you are using to get the user input.
A good website to keep in mind when doing BCB development is http://www.bcbdev.com. It's run by Harold Howe who is a member of Borlands TeamB for C++ Builder. He has a FAQ page that has several tips about using controls that you may be interested in.

Collapse -

Good luck

by a_chadili In reply to C++Builder5 Input field

Whom ever would have to maintain your piece of C++ code will have hard to understand what you are trying to do. No comments, no naming conventions, nothing !!!

You should add a comment header explaining what control you are using, the validations, the length of your input (bound or unbound), the methods you'r invoking to achieve what you are trying to do and the parameters needed to invoke those operations, etc. etc...

I suggest you read more about OO Programming techniques and consult all the litterature exposed on specialized electronic boards ...

Good Luck

Collapse -

Assuming an edit field

by mowens In reply to C++Builder5 Input field

If you are trying to get text from a TEdit field
you would use code like the following.

String addr = AddrFld->Text;

You can get a C string from the String class
like so


I would recommend making use of the available
classes, such as Strings and TStringLists, as
much as possible. It will make your life a lot
easier. Also a good naming convention will help
a lot in maintenance. You will also not want to
have all your program logic sitting in your
event handlers.

Related Discussions

Related Forums