×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hope someone can help how can i
2

Hope someone can help how can i

Hope someone can help how can i

(OP)
Hope someone can help

how can i add ; in cetain places
e.g. numbers (1 to 4 digits)(ADD;) String text can be any length also contain &+ etc characters)(ADD;) (Price in 0:20 to 1450:00 formatt)(ADD;)(more String Txt)(ADD;) another digit

1 Coke 20 Stock 0
1; Coke; 20; Stock; 0
234 Fanta Grape & Ice Cream 65.20 Room 2
234; Fanta Grape & Ice Cream; 65.20; Room; 2
etc

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP

RE: Hope someone can help how can i

Hi,

CODE

Function SpecialParse(sText As String, Optional DELIM As String = ";") As String
    Dim a As Variant, ia As Integer
    Const SPACE = " "
'1 Coke 20 Stock 0
    a = Split(sText, SPACE)
    
    SpecialParse = a(LBound(a))
    
    If IsNumeric(a(LBound(a))) Then
        SpecialParse = SpecialParse & DELIM & SPACE
    Else
        SpecialParse = SpecialParse & SPACE
    End If
    
    For ia = LBound(a) + 1 To UBound(a) - 1
        Select Case IsNumeric(a(ia))
            Case True
                SpecialParse = SpecialParse & DELIM & SPACE & a(ia) & DELIM
            Case Else
                SpecialParse = SpecialParse & SPACE & a(ia)
        End Select
    Next
    
    If IsNumeric(a(UBound(a))) Then
        SpecialParse = SpecialParse & DELIM & SPACE & a(ia)
    Else
        SpecialParse = SpecialParse & SPACE & a(ia)
    End If
End Function 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Hope someone can help how can i

A moment of boredom had me create a (slightly clunky) regular expressions solution:

CODE

Public Function SpecialParse(sText As String, Optional DELIM As String = ";") As String
    With CreateObject("vbscript.regexp") 
        .Pattern = "(\d+(?:\.\d+)?)\s+|(\w+)\s+(?=[\d\s])"
        .Global = True
        SpecialParse = .Replace(sText, "$1$2" & DELIM & " ")
    End With
End Function 

RE: Hope someone can help how can i

GrimR,

Was any of this of any use to you?

RE: Hope someone can help how can i

Anyone home?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close