Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2007

Tip: Looking for answers? Try searching our database.

Finding the first capital letter in a string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hans - 30 Mar 2007 10:49 GMT
Does anyone have some code I can use to find the first capital letter in a
string?

I need to split off and show all characters to the left of the Capital
letter.

Thanks
Hans
Douglas J. Steele - 30 Mar 2007 12:14 GMT
Try something like the following untested air-code:

Function FirstCapital(InputString As String) As Long
' returns 0 if no capital found
Dim lngFirstCapital As Long
Dim lngLoop As Long
Dim strCurrChar As String

 lngFirstCapital = 0
 For lngLoop = 1 To Len(InputString)
   strCurrChar = Mid$(InputString, lngLoop, 1)
   If Asc(strCurrChar) >= 65 And _
     Asc(strCurrChar) <= 90 Then
     lngFirstCapital = lngLoop
     Exit For
   End If
 Next lngLoop

 FirstCapital = lngFirstCapital

End Function

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Does anyone have some code I can use to find the first capital letter in a
> string?
[quoted text clipped - 4 lines]
> Thanks
> Hans
hans.stope@shaw.ca - 31 Mar 2007 05:36 GMT
Thanks Doug, That was awesome. It helped me finish my project.

Thanks again,
Hans
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.