473,397 Members | 2,099 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,397 software developers and data experts.

String Function

I need to read the contents of a dropdown listbox up to a space and then eliminate everything to the right of the space(including the space). How do I do this

Thanks

Dave
Nov 16 '05 #1
5 8852
Dave,

The drop down list has an Items property which I believe you can use to
get the items in the drop down list. You can cycle through these items and
parse the strings as you see fit.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave Bailey" <an*******@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
I need to read the contents of a dropdown listbox up to a space and then eliminate everything to the right of the space(including the space). How do
I do this?
Thanks,

Dave

Nov 16 '05 #2
Hi dave,

String.SubString can do it.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dave Bailey" <an*******@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
I need to read the contents of a dropdown listbox up to a space and then eliminate everything to the right of the space(including the space). How do
I do this?
Thanks,

Dave

Nov 16 '05 #3
Dave Bailey <an*******@discussions.microsoft.com> wrote:
I need to read the contents of a dropdown listbox up to a space and
then eliminate everything to the right of the space(including the
space). How do I do this?


Use IndexOf to find the first space, and Substring to retrieve a
portion of the string:

int index = original.IndexOf(' ');

string trimmed = (index==-1 ? original : original.Substring(0,index));

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Thanks for all the help. I am using the following code

private string GetSystemCode(

string code = sysCodeList.SelectedItem.ToString()
int offset = code.IndexOf(' ')

if (systemCodeCheck.Checked == true

return " and wo3 = '" + ((offset == -1)? code: code.Substring(0, offset)) + "'"

els

return null

Thuis code is part of a select statement which is the where clause. It appears that this code does not trim the drop down list box to the information that is on the left side of the first space.

Any suggestions

Thanks

Dave
Nov 16 '05 #5
Dave Bailey <an*******@discussions.microsoft.com> wrote:
Thanks for all the help. I am using the following code:

private string GetSystemCode()
{
string code = sysCodeList.SelectedItem.ToString();
int offset = code.IndexOf(' ');

if (systemCodeCheck.Checked == true)
{
return " and wo3 = '" + ((offset == -1)? code: code.Substring(0,
offset)) + "'";
}
else
{
return null;
}
}

Thuis code is part of a select statement which is the where clause.
It appears that this code does not trim the drop down list box to the
information that is on the left side of the first space.

Any suggestions?


Yes - step through it, find out what offset is, find out what code is,
find out what the returned value is, etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
9
by: Danny | last post by:
HI again Is there a nifty function in access that will: 1. return the amount of occurances of a small string within a larger string? this<br>is<br>a<br>test would return 3 for <br>
4
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string...
4
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
18
by: intercom5 | last post by:
I'm writing a program in C, and thus have to use C strings. The problem that I am having is I don't know how to reallocate the space for a C string outside the scope of that string. For example:...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
5
by: Sia Jai Sung | last post by:
Hi, I have a class that I modify from a sample program, like below ========================================== Imports System Imports System.Web.UI Imports System.Security.Cryptography ...
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
17
by: Tom | last post by:
Is there such a thing as a CONTAINS for a string variable in VB.NET? For instance, I want to do something like the following: If strTest Contains ("A","B", "C") Then Debug.WriteLine("Found...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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.