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
414 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Novice question on VBScript 8 60
Scraping specific data within an XML document 19 56
network copying issue 4 66
How can I modify this Excel worksheet with a script? 15 82
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…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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