Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: ComboBox to fetch only the numbers


This question is answered.


Permlink Replies: 4 - Last Post: Jun 24, 2014 2:42 AM Last Post By: Alain Bastien
Mohammad Alsharif

Posts: 36
Registered: 6/29/14
ComboBox to fetch only the numbers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 23, 2014 6:03 AM
Hi There,

I am using ComboBox in C++ XE5 to show the available COM Ports in my PC, but what I need is that it shows only the number of the port not the whole name,
i.e. only 5 instead of COM5. So how can I make the combobox fetch only the number "5" and show it in the list?

Thanks in advance
Asger Joergensen

Posts: 370
Registered: 11/18/08
Re: ComboBox to fetch only the numbers
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 23, 2014 11:36 PM   in response to: Mohammad Alsharif in response to: Mohammad Alsharif
Hi Mohammad

Mohammad Alsharif wrote:

Hi There,

I am using ComboBox in C++ XE5 to show the available COM Ports in my PC, but
what I need is that it shows only the number of the port not the whole name,
i.e. only 5 instead of COM5. So how can I make the combobox fetch only the
number "5" and show it in the list?

String removeAlphaChars( const String source )
{
   String res;
   int C = source.Length();
   for( int i = 1; i <= C; ++i )
   {
      if( source[i] >= L'0' && source[i] <= L'9' )
         res += source[i];
   }
 
   return res;
}
 
void __fastcall TForm1::Button5Click(TObject *Sender)
{
   String test = L"COM5";
   ComboBox->Items->Add( removeAlphaChars( test ) );
}


Best regards
Asger-P

MacroMenu: Store clips, macros, mail templates, bogmarks and a lot more.
View the video: http://asger-p.dk/software/macromenu.php#QuickTour

Alain Bastien

Posts: 153
Registered: 11/12/01
Re: ComboBox to fetch only the numbers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 24, 2014 12:14 AM   in response to: Asger Joergensen in response to: Asger Joergensen
Take a look at www.deepsoftware.com
Asger Joergensen

Posts: 370
Registered: 11/18/08
Re: ComboBox to fetch only the numbers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 24, 2014 1:12 AM   in response to: Alain Bastien in response to: Alain Bastien
Hi Alain

Alain Bastien wrote:

Take a look at www.deepsoftware.com

Anything specific you think I should see ??

Best regards
Asger-P

MacroMenu: Store clips, macros, mail templates, bogmarks and a lot more.
View the video: http://asger-p.dk/software/macromenu.php#QuickTour
Alain Bastien

Posts: 153
Registered: 11/12/01
Re: ComboBox to fetch only the numbers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 24, 2014 2:42 AM   in response to: Asger Joergensen in response to: Asger Joergensen
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02