|
-
Aug 6th, 2001, 11:55 PM
#1
Thread Starter
Junior Member
Urgent: Please help
Hi.
Just did a few searches, but i couldn't find what i need. I am at work right now, and this has to be finished within an hour. So please, help me out.
I have a textbox (in Acces97) that holds the initials of someone's name. Mine for example would be just K. Or it could be more letters, like T.H.G. etc. Now the tricky part is: When the focus leaves the textbox, there should be running a function that checks the string. It needs to check to see if there are points or not. If not, they need to be put there. Example: THG -> T.H.G.
I hope someone has a solution. thanx in advance.
NeoMotion
VB 6.0
Almost MCP ;-)
Allround nice guy
-
Aug 7th, 2001, 12:03 AM
#2
PowerPoster
Hi
This is either very easy or very hard. Will the first part of the entry before say a space always be initials? Or could it also be the person's full first name? If it is initials OR names will initials always be indicated by capital letters? Can u pls just provide a little more info on the conditions so that I and others can help u more.
Regards
Stuart
-
Aug 7th, 2001, 12:11 AM
#3
Thread Starter
Junior Member
They will always be initials, and not full names. I am not sure if they are capital. The functions needs to read the string, then go by them one by one if they are letters or a "." If it is a ".", it needs to do nothing, and move on to the next character.
If it is a letter, it needs to check the following character. If that is not a ".", it needs to put one there. If it is a ".", then it should move on to the next one. I hope this all makes sense. Thanx.
NeoMotion
VB 6.0
Almost MCP ;-)
Allround nice guy
-
Aug 7th, 2001, 12:11 AM
#4
-= B u g S l a y e r =-
Hi, maybe u can use something like this ?
VB Code:
Private Sub Command3_Click()
Dim s As String
Dim ss As String
Dim sNext As String
Dim i As Integer
For i = 1 To Len(Text1.Text)
s = Mid(Text1.Text, i, 1)
sNext = Mid(Text1.Text, i + 1, 1)
If s <> "." Then
If sNext <> "." Then
ss = ss & s & "."
Else
ss = ss & s
End If
Else
ss = ss & s
End If
Next i
MsgBox ss
End Sub
-
Aug 7th, 2001, 12:28 AM
#5
Thread Starter
Junior Member
Thank you, that is just what i needed. It works like a purring kitty! You saved the day.
NeoMotion
VB 6.0
Almost MCP ;-)
Allround nice guy
-
Aug 7th, 2001, 12:32 AM
#6
PowerPoster
This is a bit diff to Peet's cos actually forms whole name with initials based on ur original entry... besides he posted while i was typing 
Regards
Stuart
VB Code:
Private Sub Command1_Click()
Dim llngFirstSpace As Long 'Sorry for all Dims but just added to hopefully make more sense
Dim lstrText As String
Dim lstrInitials As String
Dim lstrSecondName As String
Dim lintCounter As Integer
Dim lstrResult As String
lstrText = Text1.Text 'Read into array for easier handling
llngFirstSpace = InStr(1, lstrText, " ") - 1 'Find occurrence of first space / indicates initials
lstrInitials = Left$(lstrText, llngFirstSpace) 'Parse off initials
lstrSecondName = Right$(lstrText, Len(lstrText) - llngFirstSpace) 'Parse off remainder
lstrInitials = Replace(lstrInitials, ".", "") 'Remove all dots before starting - saves checking
For lintCounter = 1 To Len(lstrInitials) 'Loop thru initials
lstrResult = lstrResult & Mid$(lstrInitials, lintCounter, 1)
If lintCounter < Len(lstrInitials) Then lstrResult = lstrResult & "."
'lstrResult = lstrResult & Mid$(lstrInitials, lintCounter, 1) & "."
'Commented out line adds dots after all letters instead of all but last
Next
Text2.Text = lstrResult & lstrSecondName 'Reform the name
End Sub
-
Aug 7th, 2001, 12:34 AM
#7
Thread Starter
Junior Member
Thank you also. Nice to see people helping eachother.
NeoMotion
VB 6.0
Almost MCP ;-)
Allround nice guy
-
Aug 7th, 2001, 12:34 AM
#8
-= B u g S l a y e r =-
-
Aug 7th, 2001, 12:47 AM
#9
Thread Starter
Junior Member
way inside time limit
Yep, got an half hour to spare. So thank you both very much.
NeoMotion
VB 6.0
Almost MCP ;-)
Allround nice guy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|