[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VBScript boolean string selection

Posted on 2007-03-17
3
Medium Priority
?
502 Views
Last Modified: 2010-04-09
Hi again Experts!

I'm learning VBScript and there's a construction I've used in other languages that I need to find the VBScript version of.

It's       boolean_variable("Yes", "No")       so if the variable is true it returns Yes and viceversa.

Also if I've got an integer variable how do I get text from an array of strings?  And how do I create that array?

Thanks!
Peter
0
Comment
Question by:padmasambhava
  • 2
3 Comments
 
LVL 11

Expert Comment

by:Louis01
ID: 18742715
if myBoolean then
  'True Part here
else
  'False Part here
end if

You can also use it as:
if not myBoolean then
 'False part here
end if


To create an array of 3 strings:

Dim myStringArray(2) as string
myStringArray(0)  = "Line 1"
myStringArray(0)  = "Line 2"
myStringArray(0)  = "Line 3"

Another way would be:
Dim myStringArray() As String
Dim i As Integer

For i = 0 To 2
    If i = 0 Then
        ReDim myStringArray(i)
    Else
        ReDim Preserve myStringArray(i)
    End If
    myStringArray(i) = "This is line " & i
Next i

What do you mean by "Also if I've got an integer variable how do I get text from an array of strings?"?

To return the strings created above:
for i = lbound(myStringArray) to ubound(myStringArray)
  msgbox myStringArray(i)
next i
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18743185
You can also use

NewString=If(oldString="ABC","True results","False Results")
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18743193
...and if you know your data upfront, you can create an array using

myArray=Array("Item1","Item2","Item3")

and loop through it using

For each item in myArray
  cboItems.Add item
Next
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Suggested Courses

867 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