[ uros2002 @ 31.10.2010. 17:13 ] @
Kako ovo d aupotrebim Ovo je ono sto mi treba da iz text faila procitam koji ocu red odnosno da odaberem red 2 i procita mi taj red iz nekog proba.txt ili slicno Pokusao sam da ga koristim ali mi ne polazi za rukom moze mala pomoc oko nekih problema Code (vbnet): Add this code to the very top of the code page: Imports System.IO ---------------------------------------------------------------------------------- Add the following function: Public Function ReadALine(ByVal File_Path As String, ByVal TotalLine As Integer, ByVal Line2Read As Integer) As String Dim Buffer As Array Dim Line As String If TotalLine <= Line2Read Then Return "No Such Line" End If Buffer = File.ReadAllLines(File_Path) Line = Buffer(Line2Read) Return Line End Function ----------------------------------------------------------------------------------------- Public Function GetNumberOfLines(ByVal file_path As String) As Integer Dim sr As New StreamReader(file_path) Dim NumberOfLines As Integer Do While sr.Peek >= 0 sr.ReadLine() NumberOfLines += 1 Loop Return NumberOfLines sr.Close() sr.Dispose() --------------------------------------------------------------------------------------------- To read a specific line to a textbox Dim filename As String = "C:\location\file.txt" TextBox1.Text = (ReadALine(filename, GetNumberOfLines(filename), 1)) '/Replace 1 to line # you would like to read preuzeto sa visual basic Problem mi je kako i gde da stavim ovaj kod sta mi sve treba Button i textbox ili jos nesto mozda? Sta je ovo Public Function ReadALine(ByVal File_Path As String, ByVal TotalLine As Integer, ByVal Line2Read As Integer) As String - Button? i ovo Public Function GetNumberOfLines(ByVal file_path As String) As Integer - ? gde ovo da stavim Dim filename As String = "C:\location\file.txt" TextBox1.Text = (ReadALine(filename, GetNumberOfLines(filename), 1)) Pozdrav i hvala unapred Samo da napomenem da sam pocetnik u Visual Basicu 2008 ucim ga tek mesec dana. |