Hi i have problem with separating Character from string,
e.g:
dim S as string
dim k as string
S="23 * 12 UBV 100";
how to i get output k="UBV"
Its mean only char set if together then i want to put in other variable,
any idea how to I start this.... Thx very much
4 2524
Hi,
Try this if the String Length is fixed..:
k = Mid("23 * 12 UBV 100",9,3)
Regards
Veena
Its mean only char set if together then i want to put in other variable,
If you want only characters then find out all the digits and replace them with space and finally remove space but not the intermediate spaces.
Hi,
Try this if the String Length is fixed..:
k = Mid("23 * 12 UBV 100",9,3)
Regards
Veena
Hi Veena,
Your idea is ok, however, Value of S can be change. I mean I dont know the exactvalue of S, but I know it is including with digit and character, so i want to seperate only characters, Thx again
The solution in post #3 should do the job. For example... -
Public Function CharsOnly_V1(ByVal S As String) As String
-
Dim I As Long
-
For I = 0 To 9
-
S = Replace(S, Format$(I), "")
-
Next
-
CharsOnly_V1 = Trim$(S)
-
End Function
-
Demo...
Print charsonly_v1(" db dfgjlh 35jkl sekjh 54 4") db dfgjlh jkl sekjh
Here's another alternative which has the advantage of allowing you more control over which characters are copied and which aren't. - Public Function CharsOnly_V2(ByVal S As String) As String
-
Dim I As Long, Char As String * 1
-
For I = 1 To Len(S)
-
Char = Mid$(S, I, 1)
-
Select Case Char
-
Case "0" To "9"
-
' Don't touch.
-
Case "a" To "z"
-
CharsOnly_V2 = CharsOnly_V2 & Char
-
Case "A" To "Z"
-
CharsOnly_V2 = CharsOnly_V2 & Char
-
Case Else
-
' Don't touch.
-
End Select
-
Next
-
End Function
-
Demo...
Print charsonly_v2(" db dfgjlh 35jkl sekjh 54 4") dbdfgjlhjklsekjh Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Gausebeck |
last post by:
The inability to denote data members as read-only in C++ is something
which has annoyed me (slightly) for a while now. You can always get
around it with accessor methods that return const...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: Nikolay Petrov |
last post by:
How to filter out only digits from a string?
i.e. fgfdg435fdg7dgf5:df,54 => 4357554
Thanks
|
by: Yogi_Bear_79 |
last post by:
I have the following code:
sscanf(line, "%d", n_ptr) !=1 || n_ptr <=0;
It only partially works. If the user types a character other than 0-9 to
start the string it fails. However as long as...
|
by: v4vijayakumar |
last post by:
why the following string, 'str' is read-only?
char *str = "test string";
anyhow 'str' needs to be in memory. do you think, making 'str' red-only
would gain performance? or, it is right?
|
by: YiMkiE |
last post by:
I am a newbie of C and I need to do a program to get the current date
information only, without the time. I have my code here:
#include <stdio.h>
#include <time.h>
#include <string.h>
int...
|
by: marsguy85 |
last post by:
Please help me . I am new at C , Learing C will take time but i have to submit this and i dont know how to do it honestly so please help anyone .
thanks in advance .I will understand each line of...
|
by: bcpkh |
last post by:
Hello All
I need to check a string to make sure it does not contain any non
numeric characters, the problem that I face is that the string is
fairly long, 2784601121574585949, strtol etc. can't...
|
by: dascandy |
last post by:
Hi,
I was wondering, is it possible to determine whether a string can be
modified (const char *) by the application or whether it's located in
what's commonly .rodata?
Regards,
Peter
|
by: karthikbalaguru |
last post by:
Hi,
While trying to understand the difference between the following 2
methods, i have some interesting queries.
Method 1) char *s = "Hello";
and
Method 2) char s = "Hello";
How does the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |