Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Function in vb script

rajani created the topic: function in vb script

Develop a function that accepts a string of names separated by comma add those names in an array and display the names added in the array.

rajeshkumar replied the topic: function in vb script

Welcome to board….

try following snippet…

Sub Funstr("str1", "str2")

a=Array(str1,str2)
document.write(a(0))
document.write(a(1))
End Sub

I would recommend you going through this url as well to learn more about it……

www.functionx.com/vbscript/Lesson06.htm

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajani replied the topic: function in vb script

it won’t work
i have write
“Develop a function that accepts a string of names separated by comma (example given below), add those names in an array and display the names added in the array”

Example: rajani; Disha; Dhara; Hunny ;moon
without using split function
can i use mid function

rajani replied the topic: function in vb script

i am able to display name but with comma
Dim fruits()
ReDim fruits(100)
nofruits=0
‘we do not know how many fruit names we are going to enter and so, we have declared the array size as 100
For i=0 to 100
fruits(i)=inputbox(“Enter the name of a fruit separated by comma”)
ans = MsgBox(“Do you want to continue”, vbYesNo, “Confirm Continuation…”)
If ans=vbNo Then
Exit For
End If
nofruits=nofruits+1
Next
ReDim Preserve fruits(nofruits)
‘Redim keyword resets the number of elements that can be accommodated in the array.

fruitnames=””

For each fruit in fruits
‘Using For Each Next we have displayed all the names of the fruits which was entered and kept in fruits array.
‘For Each Next extracts the fruit names stored in the array and msgbox displays the output.

fruitnames=fruitnames&fruit&vbnewline
Next

msgbox fruitnames

rajani replied the topic: function in vb script

any suggestion

rajani replied the topic: function in vb script

dim Array, Str1,X
Str1 = “Neha; Swati; Disha; Sonya; Dhara”
Array = split(Str1,”;”)
for each x in Array
message = message & x & vbCRLF
next
msgbox message

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x