Post Reply  Post Thread 
VB->c#-----HELP!!
Author Message
skiczg
Novi korisnik
*


Posts: 2
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 0
Post: #1
VB->c#-----HELP!!

Da li netko moze prevesti slijedeci dio koda iz VB-a u C#:

<code>
Dim SR as new io.StreamReader("c:\tekst.txt")
dim tekst as String = SR.ReadToEnd()
SR.Close()


dim linije() as string = tekst.split(vbCrLf) 'Carriage Return, LineFeed
(#13, #10 u ORD vrijednostima)

for Each LN as string in linije

dim ImeValue() as string = LN.Split(vbTab) 'Tabulator (#9 u ORD
vrijednosti)
if ImeValue.Length >1
dim Ime as String = ImeValue(0)
dim ValueTmp as String = ImeValue(1)
dim Value as Integer = -1
if Integer.TryParse(ValueTmp, Value) then
'ova linija je OK. IME = prvo polje, Value = broj u drugom polju
...
end if
end if
next
</code>

Hvala!!!

25-09-2007 07:00 PM
Find all posts by this user Quote this message in a reply
Puž
Redoviti posjetitelj
**


Posts: 132
Group: Registered
Joined: Mar 2007
Status: Offline
Reputation: 24
Post: #2
RE: VB->c#-----HELP!!

Code:
//na vrh metni using System.IO;


StreamReader SR = new StreamReader("c:\\\tekst.txt");
string tekst= SR.ReadToEnd();
SR.Close();

string[] linije = tekst.Split(("\r\n").ToCharArray());

foreach(string LN in linije)
{
    string[] ImeValue=LN.Split(("\t").ToCharArray());
    if (ImeValue.Length>1)
    {
             string ime=ImeValue[0];
             string ValueTmp=ImeValue[1];
             int Value=-1;
             if (int.TryParse(ValueTmp, out Value))
             {
                   //ova linija je OK. IME = prvo polje, Value = broj u drugom polju    
              }

     }
}

25-09-2007 08:45 PM
Find all posts by this user Quote this message in a reply
skiczg
Novi korisnik
*


Posts: 2
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 0
Post: #3
RE: VB->c#-----HELP!!

Puno hvala Puž!

26-09-2007 01:54 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: