ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 23rd, 2003, 02:50 PM
cinners cinners is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Pennsylvania
Posts: 30 cinners User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Question Camel Case

vb.net I have a text tob in the validation event of that text box I want to make sure thefitst word in each entry is capitialized.

ie (thanke for your help) entered in the text box should be displayed as

(Thanks For Your Help)

I just can't seem to find the code to do this

Reply With Quote
  #2  
Old June 23rd, 2003, 04:10 PM
James Yang James Yang is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Atlanta, Georgia
Posts: 284 James Yang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 45 sec
Reputation Power: 7
Send a message via ICQ to James Yang
i think u will need to code that your self.

Its not too hard....

just loop thru the string like a char array, then whenever u see a space, capitalise the next letter. It hink there is a builtin funciton for capitalisation. in Straing.Something. if not just play with ascii code
__________________
Regards,

James Yang
.NET Developer / Network Engineer
MCSE, MCDBA, MCSA, CCNA

http://www.yellowpin.com/
http://www.opentechsupport.com/

Reply With Quote
  #3  
Old June 23rd, 2003, 04:30 PM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 6
Hi Cinners
James gave you the absolute right suggestion.
However, if you still didnt solve the problem. Here is the solution.

I create 2 richtextboxs. Type your text in the richtextbox1 and click the button, you will get the expected result in the richtextbox2.
Following is the VB.NET code, designed with VS.NET.
Find the necessary codes.


Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
Friend WithEvents RichTextBox2 As System.Windows.Forms.RichTextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.RichTextBox1 = New System.Windows.Forms.RichTextBox()
Me.RichTextBox2 = New System.Windows.Forms.RichTextBox()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(88, 232)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'RichTextBox1
'
Me.RichTextBox1.Location = New System.Drawing.Point(32, 8)
Me.RichTextBox1.Name = "RichTextBox1"
Me.RichTextBox1.Size = New System.Drawing.Size(192, 88)
Me.RichTextBox1.TabIndex = 2
Me.RichTextBox1.Text = "RichTextBox1"
'
'RichTextBox2
'
Me.RichTextBox2.Location = New System.Drawing.Point(32, 112)
Me.RichTextBox2.Name = "RichTextBox2"
Me.RichTextBox2.Size = New System.Drawing.Size(192, 88)
Me.RichTextBox2.TabIndex = 3
Me.RichTextBox2.Text = "RichTextBox2"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox2, Me.RichTextBox1, Me.Button1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Public Function ProperCase(ByVal strText As String) As String 'Capitalize all first characters of the input string 'and set all the others to lowercase
On Error GoTo Err_ProperCase

Dim I As Integer, intLen As Integer, strTemp As String, strFinal As String
Dim isSpace As Boolean
strTemp = LCase(Trim(strText))
intLen = Len(Trim(strText))
isSpace = True
For I = 1 To intLen
If Mid(strTemp, I, 1) = Chr(32) Then
strFinal = Mid(strFinal, 1, I - 1) & Chr(32) & Mid(strFinal, I + 1)
isSpace = True
ElseIf isSpace Then
strFinal = Mid(strFinal, 1, I - 1) & UCase(Mid(strTemp, I, 1)) & Mid(strFinal, I + 1)
isSpace = False
Else
strFinal = Mid(strFinal, 1, I - 1) & Mid(strTemp, I, 1) & Mid(strFinal, I + 1)
End If
Next I
ProperCase = strFinal

Exit_ProperCase:
Exit Function

Err_ProperCase:
MsgBox(Err.Description & vbCrLf & strText, vbInformation, "ProperCase function")
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyStr As String
MyStr = RichTextBox1.Text
RichTextBox2.Text = ProperCase(MyStr) & ""
End Sub
End Class

Reply With Quote
  #4  
Old June 23rd, 2003, 08:41 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
lol - err - i think you may have gone a little over board iahmed... all he asked for was a capitalisation routine!

Code:
function capitalise(InString)

if InString = "" then InString = " "
InString = Replace(InString, "'","''")
FoundSpace = True
OutputString = ""
for MidPosition = 1 to len(InString)
  if FoundSpace = true then
    OutputString = OutputString & UCase(Mid(InString,MidPosition,1))
    FoundSpace = false
  else
    OutputString = OutputString & LCase(Mid(InString,MidPosition,1))
    if Mid(InString,MidPosition,1) = " " then FoundSpace = true
    if Mid(InString,MidPosition,1) = chr(10) then FoundSpace = true
  end if
next
Capitalise = trim(OutputString)
	
End Function
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #5  
Old June 23rd, 2003, 09:39 PM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 6
Mr. Stumpy
all he needed following function in my codes:

Public Function ProperCase(ByVal strText As String) As String
-----------------------------------------------------------------------------
I just wanted him to extract the needed code.


Did you get it? If not, try to remember Blaise Pacal.

once he said:

"Word differenly arranged have different meanings, and meanings differenly arranged have different effect."

Reply With Quote
  #6  
Old June 24th, 2003, 08:14 AM
cinners cinners is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Pennsylvania
Posts: 30 cinners User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Smile Thanks for all the Information

I was looking for something like this This Workes fine It just took me somt time to find it.


Private Sub txtName_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.Leave
Dim HoldText As String
HoldText = txtName.Text
txtName.Text = (StrConv(HoldText, VbStrConv.ProperCase))
End Sub

before StrConv(HoldText, bStrConv.ProperCase)


thank you for your help!

After

Thank You For Your Help!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Camel Case


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway