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

extract a substring from string

121 100+
i have a name as John smith which i enter in textbox now i want to extract John from John Smith how to do
Thanx in advance
Feb 23 '08 #1
3 1460
DGee
5
Well it depends whether you know what,where and how long the string is that you want to extract. If you do then i would use Mid(), ie the string "John Smith" = 10 characters. So (Where ever extracted to) = Mid((string or "John Smith"), (1 as "John" starts at position 1), (4 as the length of John = 4). So ... = Mid(string,1,4).


Alternativly if you had a load of strings and you needed to get the first name from all of them you could use:

data = currentname
x=1

Do
If Mid(data, X, 1) = " " Then
' end of first name
Else
' include current symbol with retrieved first name
data2 = data2 & Mid(data, X, 1)
X = X + 1
End If
Loop Until Mid(data, X, 1) = " "
'retrieved data = data2
Feb 23 '08 #2
creative1
274 100+
I think split() is a good choice for this
Feb 23 '08 #3
Killer42
8,435 Expert 8TB
I think split() is a good choice for this
Yes, you can build the logic to do pretty much whatever you want along these lines, using loops, Mid() function, and depending on your VB version, also Left() and Right() functions. But if the situation is suited to it, the Split() function will be much quicker and simpler.
Feb 25 '08 #4

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

Similar topics

1
by: Tim Smith | last post by:
I am looking to extract form element values from html, more generally I have a substring that identifies the beginning of a value and a string that identifies the end of value and I need to extract...
4
by: Lauren Quantrell | last post by:
Is there anyway to extract part of a string in a stored procedure using a parameter as the starting point? For example, my string might read: x234y01zx567y07zx541y04z My Parameter is an nvarchar...
3
by: JIM.H. | last post by:
Hi, I have this string 111_XYZ11_2345, 22_zz22_33, .., How can I extract only last numbers like 2345 and 33. Thanks, Jim.
4
by: rdraider | last post by:
Is there a function that will extract part of a string when the data you want does not occur in a specific position? Field "REF" is varchar(80) and contains an email subject line and the email...
9
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and...
1
by: Patrick Sullivan | last post by:
I am trying to extract two parts of a number from an array element. Numbers are in the format of 1.10, 2.50, 11.10, etc. Floor and ceiling won't work right because close to 1.00, I get a zero, and...
7
by: Sling | last post by:
I code in Rexx on the mainframe which has 2 built-in functions: word(s,i) & words(s). word(s,i) returns the ith word in the s(tring), and words(s) returns the number of words within the s(tring)....
13
by: Tony Girgenti | last post by:
Hello. Using VS.NET 2003 VB. If i have a string similar to the attached, how would i extract the "Truckname=" data from it in a loop and stay in the loop until the end of the string is reached...
7
by: teo | last post by:
hallo, I need to extract a word and few text that precedes and follows it (about 30 + 30 chars) from a long textual document. Like the description that Google returns when it has found a...
4
by: samuelberthelot | last post by:
Hi, I would like to extract 'some string' from the following string: <A href=\"#\">some string</A> Attention! This is not an HTML element, it is a STRING, so I can't do ..innerHTML. 'some...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.