Array and console.writeline

  • Thread starter Thread starter Leszek
  • Start date Start date
L

Leszek

Can someone help me?
Im trying to use console.writeline with ciag1.
Application must read string, split it by "," and show every section between
",".

Dim serwery_split()
Dim elementy As String()
Dim tablica(0)
Dim i As Integer = 0
Dim ciag1 = "a,b,c,d,e,f"

For i = 0 To tablica(i).lenght - 1
ReDim Preserve tablica(i)
tablica(i) = ciag1.Split(",")(0)
Console.WriteLine(tablica(i))
i = i + 1
Next
 
Hi,

Try this.

Dim tablica() As String
Dim i As Integer = 0
Dim ciag1 As String = "a,b,c,d,e,f"
tablica = ciag1.Split(","c)

For i = 0 To tablica.GetUpperBound(0)
Console.WriteLine(tablica(i))
Next

'or you can use a for each loop

For Each s As String In tablica
Console.WriteLine(s)
Next


Ken
-------------------------

Can someone help me?
Im trying to use console.writeline with ciag1.
Application must read string, split it by "," and show every section between
",".

Dim serwery_split()
Dim elementy As String()
Dim tablica(0)
Dim i As Integer = 0
Dim ciag1 = "a,b,c,d,e,f"

For i = 0 To tablica(i).lenght - 1
ReDim Preserve tablica(i)
tablica(i) = ciag1.Split(",")(0)
Console.WriteLine(tablica(i))
i = i + 1
Next
 
Thanks! That's it!

I have one more problem...
"a,b,c,d,e,f" are name of servers. I need to run Sub for every server from
this table.
But there is something wrong with execute it...
How should it looks?


example:

Sub main
Dim tablica() As String
Dim i As Integer = 0
Dim ciag1 As String = "a,b,c,d,e,f"
tablica = ciag1.Split(","c)

For i = 0 To tablica.GetUpperBound(0)
check(tablica(i))
Next
End Sub

Sub check(ByVal tablica(i) as string)
Console.WriteLine(tablica(i))
End Sub
 
Hi,

You do not need to use the same name in the sub routine. You were
passing an array to the procedure when you only needed a string. Try this
instead

Sub check(ByVal strIn as string)
Console.WriteLine(strIn)
End Sub

Ken
--------------------
Thanks! That's it!

I have one more problem...
"a,b,c,d,e,f" are name of servers. I need to run Sub for every server from
this table.
But there is something wrong with execute it...
How should it looks?


example:

Sub main
Dim tablica() As String
Dim i As Integer = 0
Dim ciag1 As String = "a,b,c,d,e,f"
tablica = ciag1.Split(","c)

For i = 0 To tablica.GetUpperBound(0)
check(tablica(i))
Next
End Sub

Sub check(ByVal tablica(i) as string)
Console.WriteLine(tablica(i))
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top