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
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals