473,386 Members | 1,720 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,386 software developers and data experts.

Capital Letters

Hi i have a program which collects the first letter of a surname depending on what the user typs i search for it in the database and display it, on the same form i have a tab filter, sorted by letters. It all works the only problem i have is if the users potentially typa "a" instead of "A" i need to capitalise it

is there a function in vb6 i can use
Mar 13 '07 #1
3 3449
I've used this in the past. It initializes the first letter of each word in a string:
Expand|Select|Wrap|Line Numbers
  1.   ' Init Caps - Make First Letter Of All Words Capitalized.
  2.   Public Shared Function InitCaps(ByVal text As String) As String
  3.     Dim c() As Char = text.ToCharArray()
  4.     Dim MakeUpper As Boolean = True
  5.  
  6.     For i As Integer = 0 To UBound(c)
  7.       If MakeUpper Then
  8.         If Char.IsLetter(c(i)) Then
  9.           c(i) = Char.ToUpper(c(i))
  10.           MakeUpper = False
  11.         End If
  12.       Else
  13.         If (Char.IsWhiteSpace(c(i))) Or _
  14.            (c(i).Equals(".".ToCharArray()(0))) Or _
  15.            (c(i).Equals("_".ToCharArray()(0))) Or _
  16.            (c(i).Equals("""".ToCharArray()(0))) Then
  17.           MakeUpper = True
  18.         Else
  19.           c(i) = Char.ToLower(c(i))
  20.         End If
  21.       End If
  22.     Next
  23.     Return New String(c)
  24.   End Function
  25.  
Mar 13 '07 #2
Killer42
8,435 Expert 8TB
...It all works the only problem i have is if the users potentially typa "a" instead of "A" i need to capitalise it

is there a function in vb6 i can use
Yes. It's the Ucase() function.

For more complex conversions, check out the StrConv() function.
Mar 14 '07 #3
Killer42
8,435 Expert 8TB
I've used this in the past. It initializes the first letter of each word in a string: ...
I hate to be the one to break it to you, but the StrConv function does that in one statement. At least, according to the online help it does.
Mar 14 '07 #4

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

Similar topics

2
by: Jeff | last post by:
Hi, I am trying to insert a space before all capital letters in a string except the first occurrence. For example: FirstSecondThird would become First Second Third Is there a regular...
4
by: Carlos Marangon | last post by:
Hello! People go to sign my guestbook and wrote all text in capital letters. Did you know any script that shows an window alert when one types the second capital letter? Best regards,
2
by: Ebi | last post by:
Hi I'm writing a project in C++ borland 5; and I need a function that get a string or char* variable and convert all of the small letters to the capital. please help me. -- Sincerely Yours...
7
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following...
1
by: Marc Verdonck | last post by:
First: I have some troubles in access, some fields needs to begin with a Capital letter. Example: louiselaan need to be Louiselaan. How can I become this? Second: I'm exporting my database to...
1
by: thomaz | last post by:
How I can place in capital letters the text of a COMBOBOX? For TEXTBOX I use: textBox1.CharacterCasing = CharacterCasing.Upper;... How to make the same for a COMBOBOX? There isnt a...
3
by: Bertha94 | last post by:
I am trying to set certain cells to capitalize any input whethere they have the caps lock on or not. I have toyed with "Private Sub Workbook_SheetChange" to turn all changes into an object with...
0
by: wbosw | last post by:
I'm trying to create a regex to find more than one capital letter position within a word. The below regex, finds the first capital letter in the word and returns the index for that character. I...
5
Presto731
by: Presto731 | last post by:
HOW do i make the letters in various fields on a form always be capital no matter if they used capital letters or not when typing?
1
by: minimatrix | last post by:
Hi guys just wandering if I could get a little help! , I have wrote a Perl script to sort out some data in my database, I am saving into an sql file but having a few problems executing the sql...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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...

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.