PC Review


Reply
Thread Tools Rate Thread

Array and console.writeline

 
 
Leszek
Guest
Posts: n/a
 
      22nd Aug 2005
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


 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      22nd Aug 2005
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
-------------------------

"Leszek" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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



 
Reply With Quote
 
Leszek
Guest
Posts: n/a
 
      22nd Aug 2005
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



Użytkownik "Ken Tucker [MVP]" <(E-Mail Removed)> napisał w wiadomości
news:(E-Mail Removed)...
> 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
> -------------------------
>
> "Leszek" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      22nd Aug 2005
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
--------------------
"Leszek" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
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



Użytkownik "Ken Tucker [MVP]" <(E-Mail Removed)> napisał w wiadomości
news:(E-Mail Removed)...
> 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
> -------------------------
>
> "Leszek" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> 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
>
>
>




 
Reply With Quote
 
Leszek
Guest
Posts: n/a
 
      22nd Aug 2005
Thanks for explaining me rules about arrays
Now i know how to use it

Użytkownik "Ken Tucker [MVP]" <(E-Mail Removed)> napisał w wiadomości
news:(E-Mail Removed)...
> 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
> --------------------
> "Leszek" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> 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
>
>
>
> Użytkownik "Ken Tucker [MVP]" <(E-Mail Removed)> napisał w wiadomości
> news:(E-Mail Removed)...
>> 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
>> -------------------------
>>
>> "Leszek" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> 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
>>
>>
>>

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Console::Writeline() Manjree Garg Microsoft VC .NET 2 7th Jan 2008 02:41 AM
Console.WriteLine vs. Debug.WriteLine formatting Zytan Microsoft C# .NET 1 27th Feb 2007 02:24 AM
Re: Console.WriteLine() Peter Bradley Microsoft C# .NET 0 19th Dec 2006 02:02 PM
Console.Writeline hangs if user click into the console window Urs Eichmann Microsoft VB .NET 3 20th Jul 2004 06:48 AM
console.writeline portroe Microsoft VB .NET 5 6th Dec 2003 11:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:30 PM.