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)]
1 1094
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 - Public Class Form1
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim animals() As String = {"Cat", "Dog", "Fish", "Horse", "Donkey", "Giraffe", "Lion", "Snake", "Elephant", "Tiger", "Bear"}
-
-
For Each animal As String In animals
-
MessageBox.Show(animal)
-
Next
-
End Sub
-
End Class
-
Here is an example using a For Next loop. - Public Class Form1
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim animals() As String = {"Cat", "Dog", "Fish", "Horse", "Donkey", "Giraffe", "Lion", "Snake", "Elephant", "Tiger", "Bear"}
-
-
For i As Integer = 0 To animals.Length - 1
-
MessageBox.Show(animals(i))
-
Next
-
End Sub
-
End Class
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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.
|
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
|
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...
|
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...
|
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...
|
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...
|
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
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |