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

x
?
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
Medium Priority
?
421 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 1000 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 1000 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 1000 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 1000 total points
ID: 35143618
Line 2 should be
String2="Hello"

Rob.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

722 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