Results 1 to 9 of 9

Thread: Urgent: Please help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    22

    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

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    22
    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

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Hi, maybe u can use something like this ?

    VB Code:
    1. Private Sub Command3_Click()
    2.     Dim s As String
    3.     Dim ss As String
    4.     Dim sNext As String
    5.     Dim i As Integer
    6.    
    7.    
    8.     For i = 1 To Len(Text1.Text)
    9.         s = Mid(Text1.Text, i, 1)
    10.         sNext = Mid(Text1.Text, i + 1, 1)
    11.         If s <> "." Then
    12.             If sNext <> "." Then
    13.                 ss = ss & s & "."
    14.             Else
    15.                 ss = ss & s
    16.             End If
    17.         Else
    18.             ss = ss & s
    19.         End If
    20.     Next i
    21.     MsgBox ss
    22. End Sub
    -= a peet post =-

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    22
    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

  6. #6
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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:
    1. Private Sub Command1_Click()
    2.     Dim llngFirstSpace As Long 'Sorry for all Dims but just added to hopefully make more sense
    3.     Dim lstrText As String
    4.     Dim lstrInitials As String
    5.     Dim lstrSecondName As String
    6.     Dim lintCounter As Integer
    7.     Dim lstrResult As String
    8.    
    9.     lstrText = Text1.Text 'Read into array for easier handling
    10.     llngFirstSpace = InStr(1, lstrText, " ") - 1 'Find occurrence of first space / indicates initials
    11.     lstrInitials = Left$(lstrText, llngFirstSpace) 'Parse off initials
    12.     lstrSecondName = Right$(lstrText, Len(lstrText) - llngFirstSpace) 'Parse off remainder
    13.     lstrInitials = Replace(lstrInitials, ".", "") 'Remove all dots before starting - saves checking
    14.  
    15.     For lintCounter = 1 To Len(lstrInitials) 'Loop thru initials
    16.         lstrResult = lstrResult & Mid$(lstrInitials, lintCounter, 1)
    17.         If lintCounter < Len(lstrInitials) Then lstrResult = lstrResult & "."
    18.         'lstrResult = lstrResult & Mid$(lstrInitials, lintCounter, 1) & "."
    19.         'Commented out line adds dots after all letters instead of all but last
    20.     Next
    21.     Text2.Text = lstrResult & lstrSecondName 'Reform the name
    22. End Sub
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    22

    Talking

    Thank you also. Nice to see people helping eachother.
    NeoMotion
    VB 6.0
    Almost MCP ;-)
    Allround nice guy

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by Neomotion
    Thank you, that is just what i needed. It works like a purring kitty! You saved the day.
    glad I could help.. was it within ur 1hour limit ?
    -= a peet post =-

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    22

    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
  •  



Click Here to Expand Forum to Full Width