473,499 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find out if character is in caps or not?

What I really need is a short simple solution for this scenario:

Imagine word like this:
"TheSimpleSolution"
I need to turn it to:
"The Simple Solution"

I need a solution, something which would turn connected words and
separate them using spaces. Basically, a script which would add the
space ahead of each capitalized character.

Please, be so good and let me know, I know I am pretty much asking for
ready script, but whatever you mention, whatever help or sugestion
will be much appreciated.

Thanks a lot.
Martin

Nov 21 '05 #1
8 963
Here she goes Martin...

Public Function SplitWords(ByVal s as string) as string
Dim strAns as string
Dim c as char

For Each c in s
If Char.IsUpper(c) Then
strAns += " "
End If

strAns += c
Next

Return strAns
End Function

-Fabricio
fg*************@yahoo.com

"Martin Ho" wrote:
What I really need is a short simple solution for this scenario:

Imagine word like this:
"TheSimpleSolution"
I need to turn it to:
"The Simple Solution"

I need a solution, something which would turn connected words and
separate them using spaces. Basically, a script which would add the
space ahead of each capitalized character.

Please, be so good and let me know, I know I am pretty much asking for
ready script, but whatever you mention, whatever help or sugestion
will be much appreciated.

Thanks a lot.
Martin

Nov 21 '05 #2
Fabricio ,
I don't know how to thank you... you saved me a lot of time and I
really appreciate it.
Thanks a lot.
Martin

backup of this question:
http://www.groupsrv.com/dotnet/viewtopic.php?t=69327

Nov 21 '05 #3
Fabricio,

Seeing your code I am sure you know the Stringbuilder and just are thinking
something as "why use that for such a simple string".

I have seen that even for short strings the stringbuilder gives beter result
and sometimes OPs are giving a simple sample to use it for long strings.

For Martin, with the stringbuilder the code from Fabricio can be.

Public Function SplitWords(ByVal s as string) as string
Dim strAns as new system.text.stringbuilder
Dim c as char
For Each c in s
If Char.IsUpper(c) Then
strAns.append( " ")
End If
strAns.append(c)
Next
Return strAns.tostring
End Function


Cor
Nov 21 '05 #4
* ja*******@gmail-dot-com.no-spam.invalid (Martin Ho) scripsit:
Imagine word like this:
"TheSimpleSolution"
I need to turn it to:
"The Simple Solution"

I need a solution, something which would turn connected words and
separate them using spaces. Basically, a script which would add the
space ahead of each capitalized character.


\\\
Imports System.Text
..
..
..
MsgBox(ExpandCaps("ThisIsVeryGood"))
..
..
..
Public Function ExpandCaps(ByVal Text As String) As String
Dim Buffer As New StringBuilder(CInt(Text.Length * 1.3))
For Each c As Char In Text
If Char.IsUpper(c) Then
Buffer.Append(" "c)
End If
Buffer.Append(c)
Next c
Return Buffer.ToString()
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5
I don't use the Stringbuilder object much... actually I've never used it.
When you say it "gives better results" do you mean performance. Is it more
efficient than a built-in string object. Also, how's its overhead compared
to the string object? Thanks for the info Cor.

-Fabricio
fg*************@yahoo.com

P.S. What's OP?

"Cor Ligthert" wrote:
Fabricio,

Seeing your code I am sure you know the Stringbuilder and just are thinking
something as "why use that for such a simple string".

I have seen that even for short strings the stringbuilder gives beter result
and sometimes OPs are giving a simple sample to use it for long strings.

For Martin, with the stringbuilder the code from Fabricio can be.

Public Function SplitWords(ByVal s as string) as string
Dim strAns as new system.text.stringbuilder
Dim c as char
For Each c in s
If Char.IsUpper(c) Then
strAns.append( " ")
End If
strAns.append(c)
Next
Return strAns.tostring
End Function


Cor

Nov 21 '05 #6
No problem bud :-)

-Fabricio
fg*************@yahoo.com

"Martin Ho" wrote:
Fabricio ,
I don't know how to thank you... you saved me a lot of time and I
really appreciate it.
Thanks a lot.
Martin

backup of this question:
http://www.groupsrv.com/dotnet/viewtopic.php?t=69327

Nov 21 '05 #7
* "=?Utf-8?B?RmFicmljaW8=?=" <Fa******@discussions.microsoft.com> scripsit:
I don't use the Stringbuilder object much... actually I've never used it.
When you say it "gives better results" do you mean performance. Is it more
efficient than a built-in string object.


Strings in .NET are immutable, contantenating two strings will create a
new string object that consists of the concatenated strings. 'StringBuilder'
overcomes this issue.

I suggest to take a look at the documentation for the 'System.String'
and 'System.Text.StringBuilder' classes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #8
Fabricio,

I can can add a lot to the message from Herfried,

What he not explained was OP which means Original Poster

However when you have still question, feel free to ask.

Cor
I don't use the Stringbuilder object much... actually I've never used it.
When you say it "gives better results" do you mean performance. Is it more efficient than a built-in string object. Also, how's its overhead compared to the string object? Thanks for the info Cor.

-Fabricio
fg*************@yahoo.com

P.S. What's OP?

Nov 21 '05 #9

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

Similar topics

8
7612
by: Mr. B | last post by:
In VB6, I had some code which 'forced' the first character of a string entered to be Capital. For example, if a person was entering their name (john doe)... the code would 'force' --- John Doe. ...
18
4895
by: Robert | last post by:
Hi! I was wondering if the was any way to determine the state of the caps lock key, on or off. Of course I can capture the key events and see whether the caps lock is pressed, but that does not...
4
6613
by: Peter D | last post by:
I have a second hand bar code reader (keyboard wedge) en i can read the bar codes but after every scan he turns my caps lock on. (GRRRRRR). I search a code to turn my caps lock off or can anyone...
20
1969
by: Malcolm | last post by:
Use all lower case for ansi c functions, and Capitalise For Platform-Specific. If you call something with caps, then your function name requires caps itself.
5
1739
by: JrMc | last post by:
I am new to this .net environement. I'm needing to do a simple task - I need to read the first character of a word and replace it with an uppercase. Example: "horse" --> change to "Horse" ...
7
3884
by: John A Grandy | last post by:
does anyone know of an intrinsic .NET function , or font , or other mechanism , to do "proper-case all-caps" ... ? so, for a name like "Arnold Schwarzenegger" ... .... I want it entirely in...
9
1563
by: trondhuso | last post by:
Hi, I have a solution that - at time of writing - has to use tables to render a list of database-results. My challenge though is that we have used iframes and such to render the different lists...
7
3565
by: Keith Thompson | last post by:
"mkeles84" <mkeles84@hotmail.comwrites: comp.std.c deals with the C standard -- the document, how it's developed, and so forth. comp.lang.c deals with the C language, and that's where your...
18
15603
by: DanicaDear | last post by:
I want to use all caps in a database. I desire to show all caps AS YOU TYPE regardless of how the keyboard/caps lock is set. I tried to format my form field with an on-click event…and this is the...
0
7009
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
7223
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
7390
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
5475
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,...
1
4919
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...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.