Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Semrush - keyword research tool

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Teach Your Child To Read

Disclosure: My content contains affiliate links.

31,648 questions

41,701 answers

573 users

How to use for each in VB.NET

3 Answers

0 votes
Imports System

Public Class ForEach_VB
    Public Shared Sub Main(ByVal args As String())
		Dim names() As String = {"Sophia", "Emma", "Emily", "Ava", "Isabella", "Zoe"}
 
        For Each nm As String In names
            Console.WriteLine(nm)
        Next
     
	End Sub
 
End Class
 
 
 
' run:
'
' Sophia
' Emma
' Emily
' Ava
' Isabella
' Zoe
'


Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered May 24, 2015 by avibootz
edited Jul 8 by avibootz
0 votes
Imports System

Public Class ForEach_VB
    Public Shared Sub Main(ByVal args As String())
		Dim arr() As Integer = {7, 13, 31, 18, 120, 331, 1600, 7000000, 130000000}
 
        For Each number As Integer In arr
            Console.WriteLine(number)
        Next
 
    End Sub
 
End Class
 
 
 
' run:
'
' 7
' 13
' 31
' 18
' 120
' 331
' 1600
' 7000000
' 130000000
'

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Feb 7, 2016 by avibootz
edited Jul 8 by avibootz
0 votes
Imports System
Imports System.Collections.Generic
 
Public Class ForEach_VB
    Public Shared Sub Main(ByVal args As String())
        Dim lst As New List(Of String)(New String() {"vb", "c", "c++", "java"})
 
        For Each item As String In lst
            Console.WriteLine(item)
        Next
    End Sub
End Class
 
 
 
' run:
'
' vb 
' c 
' c++ 
' java
'

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Jul 8 by avibootz

Related questions

1 answer 68 views
1 answer 79 views
2 answers 133 views
1 answer 57 views
1 answer 72 views
...