473,397 Members | 1,974 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.

Capitalize First Character?

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.

Here is what I believe is the VB6 code:

Private Sub txbModUser_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txbModUser.TextChanged
KeyAscii = AutoType(Screen.ActiveControl, KeyAscii)
End Sub

Public Function AutoType(ByVal c As Control, ByVal KeyAscii As Integer) As
Integer
' Forces Uppercase for First Character in String
AutoType = KeyAscii
If KeyAscii > 95 And KeyAscii < 123 Then
If c.SelStart = 0 Then
AutoType = AutoType - 32
ElseIf Mid$(c.Text, c.SelStart, 1) < "!" Then
AutoType = AutoType - 32
End If
End If
End Function
Is there a way to do this in VB.net?

Also, how can I toggle the Caps Lock Key? I know it's something to do with
"System.Windows.Forms.Keys.CapsLock". But how to test for it on/off?

Thanks!

Bruce
Jul 21 '05 #1
8 7606
Cor
Hi Mr. B,
Take a look at:
str = StrConv(str, vbProperCase)
Cor
Jul 21 '05 #2
Hi, It's easier than you think, in VB.NET and in VB6:

Dim strName As String = "tom spink"

strName = StrConv(strName, VbStrConv.ProperCase)

MsgBox(strName)

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Mr. B" <Us**@NoWhere.Com> wrote in message
news:ek********************************@4ax.com...
: 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.
:
: Here is what I believe is the VB6 code:
:
: Private Sub txbModUser_TextChanged(ByVal sender As System.Object, ByVal
e As
: System.EventArgs) Handles txbModUser.TextChanged
: KeyAscii = AutoType(Screen.ActiveControl, KeyAscii)
: End Sub
:
: Public Function AutoType(ByVal c As Control, ByVal KeyAscii As Integer)
As
: Integer
: ' Forces Uppercase for First Character in String
: AutoType = KeyAscii
: If KeyAscii > 95 And KeyAscii < 123 Then
: If c.SelStart = 0 Then
: AutoType = AutoType - 32
: ElseIf Mid$(c.Text, c.SelStart, 1) < "!" Then
: AutoType = AutoType - 32
: End If
: End If
: End Function
:
:
: Is there a way to do this in VB.net?
:
: Also, how can I toggle the Caps Lock Key? I know it's something to do
with
: "System.Windows.Forms.Keys.CapsLock". But how to test for it on/off?
:
: Thanks!
:
: Bruce
Jul 21 '05 #3
Hello,

"Mr. B" <Us**@NoWhere.Com> schrieb:
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. [...] Is there a way to do this in VB.net?
\\\
s = StrConv("john doe", VbStrConv.ProperCase)
///
Also, how can I toggle the Caps Lock Key? I know it's
something to do with "System.Windows.Forms.Keys.
CapsLock". But how to test for it on/off?


Untested:

\\\
MsgBox((Control.ModifierKeys And Keys.CapsLock) = Keys.CapsLock)
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Jul 21 '05 #4
With Deft Fingers, "Cor" <no*@non.com> wrote:
Hi Mr. B,
Take a look at:
str = StrConv(str, vbProperCase)


Yeah! Thanks!

Bruce
Jul 21 '05 #5
With Deft Fingers, "Tom Spink" <th**********@ntlworld.com> wrote:
Hi, It's easier than you think, in VB.NET and in VB6:


Yeah it sure was/is!

Thanks!

Bruce
Jul 21 '05 #6
With Deft Fingers, "Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote:
Is there a way to do this in VB.net?

s = StrConv("john doe", VbStrConv.ProperCase)


Thanks. That seems to be 'the' way.
something to do with "System.Windows.Forms.Keys.
CapsLock". But how to test for it on/off?

Untested:
MsgBox((Control.ModifierKeys And Keys.CapsLock) = Keys.CapsLock)


Well I get "False" in both cases (on/off). I'll play with it a bit.

Thanks.

Bruce
Jul 21 '05 #7
Hello,

"Mr. B" <No*****@address.not> schrieb:
Untested:
MsgBox((Control.ModifierKeys And Keys.CapsLock)

= Keys.CapsLock)

Well I get "False" in both cases (on/off). I'll play with it a bit.


Sorry, that won't work. Forget about that. You will have to use pinvoke
with 'GetAsyncKeyState'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Jul 21 '05 #8
With Deft Fingers, "Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote:
Sorry, that won't work. Forget about that. You will have to use pinvoke
with 'GetAsyncKeyState'.


Not to worry... with your 'leeetttlle' bit o' code, it resolved the 'need' to
check for Caps Lock (I was going to 'force' lower case input, then capitalize
the first letter). Nada now (:

Thx

Bruce
Jul 21 '05 #9

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

Similar topics

10
by: Aaron | last post by:
string a = "i have an apple"; i want the output to be "I Have An Apple"; i was able to capitalize the first word but can't figure out how to capitalize every word in that string Thanks,...
7
by: Marek Mand | last post by:
<script> var newval = ''; var name = 'marek mänd-österreich a'; // http://www.faqts.com/knowledge_base/view.phtml/aid/15940 correctedname = name.replace(/\b\w+b/g, function(word) { return ...
4
by: sams | last post by:
First, I'll tell you up front that I am clueless when it comes to Javascript. So I apologize if this question is off topic. I have a nice little Javascript that capitalizes each field in my...
3
by: gil | last post by:
I have a script that will capitalize the first letter of every word in my descriptions. But some of my descriptions contain ( ) and /. For example bezel (black). I need the script to capitalize...
5
by: DDK | last post by:
What is the best way to capitalize the first letter of a string? Thanks for any help, d.
8
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. ...
1
blyxx86
by: blyxx86 | last post by:
I have the code to capitalize an entire string when it is input, but would like to capitalize just the first letter of a box, or match the case of a drop down list.. My current code is thus: ...
5
by: fAnSKyer/C# newbie | last post by:
Sorry for this stupid question. I am using c way s = s -'a' +'A' but I can't compile it. Thanks for your kind help Best wishes
12
by: jackson.rayne | last post by:
Hello, I am a javascript newbie and I'm stick at one place. I have a requirement where I will get a sentence in a variable example var v1 ="This is a sentence"
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.