?
Solved

How do you compare multiple strings at once

Posted on 2005-04-15
2
Medium Priority
?
202 Views
Last Modified: 2012-06-21
To: All

I would like to compare multiple strings at once.  I want to see if there all the same.

The below example doesn't work.

Dim stringA as String
Dim stringB as String
Dim stringC as String

stringA = "help"
stringB = "help"
stringC = "help"

if(stringA = stringB = stringC) Then
  MessageBox.show("all equal")
End If


0
Comment
Question by:vaultworld
2 Comments
 
LVL 12

Accepted Solution

by:
S-Twilley earned 2000 total points
ID: 13792871
Dim stringA as String
Dim stringB as String
Dim stringC as String

stringA = "help"
stringB = "help"
stringC = "help"

if(stringA = stringB  AndAlso stringB = stringC) Then
  MessageBox.show("all equal")
End If

==================

I only just learnt about the AndAlso operator... it won't bother going onto the second comparison if the first one fails
0
 
LVL 1

Author Comment

by:vaultworld
ID: 13793149
Very Cool,  Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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