Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


searchng a string

Posted on 1999-07-07
Medium Priority
Last Modified: 2010-05-02
If i have a string..say containing "me:You"
How can i use code to divide this string into two string containing the data before the : and the other string containing the data after.

eg original string = me:you
NewString One must = me
NewStringTwo must = you

How can i do this plz?
Question by:vbkann
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

slgal earned 80 total points
ID: 1522637
   Dim strOrg As String
    Dim str1 As String
    Dim str2 As String
    Dim nPos As Integer
    strOrg = "me:You"
    nPos = InStr(1, strOrg, ":")
    str1 = Mid(strOrg, 1, nPos - 1)
    str2 = Mid(strOrg, nPos + 1)

Hope it helps :>~
LVL 22

Expert Comment

ID: 1522638

If you have VB6, there is an even neater way... The brand new 'Split' function splits a delimited string into an array. Like this:

Sub TryThis()
  Dim txt, arr, i
  txt = "Me:and:you:Mary:and:Peter"
  arr = Split(txt, ":")
  For i = LBound(arr) to Ubound(arr)
    Msgbox arr(i)
  Next i
End Sub

Ture Magnusson
Karlstad, Sweden

Author Comment

ID: 1522639 i dont have vb6 ..yet but thanks anyway

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question