473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Getting values from a combobox?

Hello

I want to use a combobox to select which COM port on the pc my interface uses.

at the moment i'm using this (which dose not work)
private: System::Void button6_Click(System::Object * sender, System::EventArgs * e)
{
char com[4];

for(int k=0;k<comboBox1->Text->Length;k++)
com[k]=comboBox1->Text->Chars[k];
SerialPort.Open(com, 19200);
}

i get the warning message: conversion from '__wchar_t' to 'char', possible loss of data.

in the combobox drop down bit is "COM1,COM2,COM3,COM4,COM5,COM6,COM7,COM8"

Is there a way to make this work in c++??
May 31 '07 #1
5 2592
weaknessforcats
9,208 Expert Mod 8TB
Any reason this cannot be a wchar_t array?

Expand|Select|Wrap|Line Numbers
  1. char com[4];
  2.  
If memory serves, you aren't supposed to use char around COM.
May 31 '07 #2
[quote=weaknessforcats]Any reason this cannot be a wchar_t array?

Expand|Select|Wrap|Line Numbers
  1. char com[4];
  2.  
nope. thanks for that, i was trying to make too complicated as usual

I'll give it a go, but will let know if there are any other problems
May 31 '07 #3
i think it maby dose need to be a char array
because i did as you said and got this
error C2664: 'CComPort::Open' : cannot convert parameter 1 from 'wchar_t [4]' to 'char *'


unless there is a way to convert wchar_t to char?
May 31 '07 #4
i think it maby dose need to be a char array
because i did as you said and got this
error C2664: 'CComPort::Open' : cannot convert parameter 1 from 'wchar_t [4]' to 'char *'


unless there is a way to convert wchar_t to char?
hah! it would be better to just make it a char array, or maybe use an intermediate variable for conversion purposes.
Jun 1 '07 #5
hah! it would be better to just make it a char array, or maybe use an intermediate variable for conversion purposes.
What is a "intermediate variable" and how would I use it for conversion purposes?
Jun 1 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
2
by: Balamurukan | last post by:
How to retrive property values from our own property window
5
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound...
5
by: James P. | last post by:
Hello, For my new Windows application, all I want is to create an initial form to demo to the user to show them how it looks like with some data on it. So I figure the fastest way is to create...
2
by: Becker | last post by:
I have a need for a simple combobox on a form in one of my programs that represents city, state. I want to have it autocomplete as the user types. I have a table with these values (about 50k of...
3
by: lakepeir | last post by:
Hello, I'm have defined a combobox on form2 and I'm trying to use that value in form1. I have defined a global value so that form1 can retrieved the modified value as: Public Shared...
1
by: kswapna13 | last post by:
Hi, I have doubt pls rectifythat,in jsp page iam having combobox of class which consists of various classes below that one empty subject combobox,from above class combobox if we select...
7
oll3i
by: oll3i | last post by:
i want to change the values in two columns one colum is a combobox and the secons column is editable too i want to get the value of that second column and the value of combobox and sent that...
1
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.