Hi friends i have a big problem... i want only the first Character to be Upper and all the rest lower and then the next name to be upper and then lower.. for eX. Geeta Lopez
Can u Plz Help Me

Dani AI

Generated

asked for each word in a textbox to be "First letter upper, rest lower" and pointed to the VB built‑in proper‑case routine — that is the quickest fix. For real input you should also trim/collapse whitespace, be culture‑aware, and handle punctuation inside names (apostrophes, hyphens). The short recipe is: normalize spacing, lowercase everything with the right culture, convert to title case, then fix characters that follow punctuation (apostrophes, hyphens). Call this on submit (server side) or on the textbox leave/save event; do client‑side formatting if you want to avoid postbacks.

A compact VB.NET routine that follows the steps above:

Imports System.Globalization
Imports System.Text.RegularExpressions

Public Function ProperName(input As String) As String
    If String.IsNullOrWhiteSpace(input) Then Return String.Empty
    Dim ci As CultureInfo = CultureInfo.CurrentCulture
    Dim ti As TextInfo = ci.TextInfo
    Dim cleaned As String = Regex.Replace(input.Trim(), "\s+", " ").ToLower(ci)
    cleaned = ti.ToTitleCase(cleaned)
    cleaned = Regex.Replace(cleaned, "(['-])([a-z])", Function(m) m.Groups(1).Value & ti.ToUpper(m.Groups(2).Value))
    Return cleaned
End Function

Usage example:

TextBox1.Text = ProperName(TextBox1.Text)

Notes and pitfalls:

  • Use the current or a chosen CultureInfo to avoid surprises (Turkish dotted/dotless i).
  • Some names (McDonald, O'Neil, van der Meer, acronyms like USA) need custom rules or an exceptions list.
  • For ASP.NET WebForms, run this on server when saving (or on TextChanged with AutoPostBack) to keep logic centralized; for immediate UI feedback, mirror it in client JavaScript.
  • Microsoft references: Strings.StrConv and TextInfo.ToTitleCase.

Recommended Answers

All 3 Replies

Here's a example on how it is done..

Dim a As String = "geeta lopez"
        MsgBox(StrConv(a, VbStrConv.ProperCase))

Hi ivatanako, thanks 4 ur answer. i have nt mention it earlier but i want any name that i type in a textbox to be like this not only ''geeta lopez".

If I understand you clearly,

StrConv(textbox1.text, VbStrConv.ProperCase)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.