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
420 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
[X]
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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

636 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