473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

visual basics string manipulation.

Dim animals() As String = {"Cat", "Dog", "Fish", "Horse", "Donkey", "Giraffe", "Lion", "Snake", "Elephant", "Tiger", "Bear"}


Using a For Loop, which code can i use to display these animals in a MsgBox [(one by one)]
Aug 21 '14 #1
1 1093
IronRazer
83 64KB
Hi,
You can use a For Each loop or a For Next loop to iterate through all the elements of the string array.

Here is an example using a For Each loop

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim animals() As String = {"Cat", "Dog", "Fish", "Horse", "Donkey", "Giraffe", "Lion", "Snake", "Elephant", "Tiger", "Bear"}
  5.  
  6.         For Each animal As String In animals
  7.             MessageBox.Show(animal)
  8.         Next
  9.     End Sub
  10. End Class
  11.  
Here is an example using a For Next loop.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim animals() As String = {"Cat", "Dog", "Fish", "Horse", "Donkey", "Giraffe", "Lion", "Snake", "Elephant", "Tiger", "Bear"}
  5.  
  6.         For i As Integer = 0 To animals.Length - 1
  7.             MessageBox.Show(animals(i))
  8.         Next
  9.     End Sub
  10. End Class
  11.  
Aug 21 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Kurien Baker Fenn | last post by:
I would like to show the progress of an application using the progress bar in visual basics using the timer.Please help me. Thanks in advance.
4
by: Jim McGivney | last post by:
Does anyone know of a concise article that covers string manipulation, such as insert, join, pad, etc. Thanks, Jim
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
5
by: Jyoti Khalap | last post by:
HI Can Anyone help me out with my problem its very urgent I want to import text file to my visual basics application because everytime its a new text file depending on that text file i want to...
0
by: cooljoel27 | last post by:
can any one of youll write a code in microsoft Visual basics for secure Hash algorithm please see additional information below (this is for my final year project) ALGORITHM  Append padding bits...
3
Mague
by: Mague | last post by:
Hey, I need help to some how open a exe file with Microsoft Visual basics. You mite think im trying to steal someone elses project but im not i wont to no how they did it and upgrade it if...
0
by: Teelokee Medha | last post by:
Hi everybody, Need help to write a program in C/C++ or visual basics for monitoring the activity of my Hard disk. Thanks. Looking Forward for hearing from you Teelokee Anoushka
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.