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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Chocolatey under PowerShell is not working properly 3 68
powershell script 9 63
VMWare Calculate number of processors 10 64
Limit the # times a macro code will run 14 50
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…

856 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