Solved

I want to search in a string1 for the existance of another string2 and want to check the character on the right of string2

Posted on 2011-03-15
4
411 Views
Last Modified: 2012-05-11
I want to check wether the character on the right of string2 equals " " or ";"  (space or semicolon)

eg. Srting1=blabla Hello;
String2=Hello

I want to check whether string2 ends with ;
0
Comment
Question by:itbabe
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
omgang earned 250 total points
ID: 35139493
OM Gang

Option Explicit

Dim strOne, strTwo, strResult
Dim intPosTwoStart, intPosTwoEnd, intTwoLen

strOne = "blabla Hello;"
strTwo = "Hello"

intPosTwoStart = InStr(strOne, strTwo)
intTwoLen = Len(strTwo)
strResult = Mid(strOne, intPosTwoStart + intTwoLen)

WScript.Echo strResult
0
 
LVL 28

Assisted Solution

by:omgang
omgang earned 250 total points
ID: 35139513
If desirable you could modify the output a bit

Option Explicit

Dim strOne, strTwo, strResult
Dim intPosTwoStart, intPosTwoEnd, intTwoLen

strOne = "blabla Hello;"
strTwo = "Hello"

intPosTwoStart = InStr(strOne, strTwo)
intTwoLen = Len(strTwo)
strResult = Mid(strOne, intPosTwoStart + intTwoLen)

If strResult = " " Then strResult = "space"
WScript.Echo strResult

OM Gang
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 250 total points
ID: 35143615
Just like this.

blnFound = False
String2=Hello
If Right(String2, 1) = " " Or Right(String2, 1) = ";" Then blnFound = True
MsgBox blnFound

Open in new window


Regards,

Rob.
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 250 total points
ID: 35143618
Line 2 should be
String2="Hello"

Rob.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now