filing plz explain me.

abdul_samad

Member
Joined
Nov 5, 2007
Messages
6
Programming Experience
1-3
hi admin plz help
this is code here filing in vb.net 2005
i dont understude this while code plz explain me while loop code plz thankx admin with step by step


VB.NET:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim srl As StreamReader
        Dim fsl As New FileStream("E:\info.txt", FileMode.Open)
        srl = New StreamReader(fsl)

        Dim itm1 As String, itm2 As String, itm3 As String, itm4 As String, itm5 As String, itm6 As String
        Dim check As Integer
        check = 0

        itm1 = srl.ReadLine
        itm2 = srl.ReadLine
        itm3 = srl.ReadLine
        itm4 = srl.ReadLine
        itm5 = srl.ReadLine
        itm6 = srl.ReadLine

        While Not itm1 = Nothing
            If itm1 = TextBox1.Text Then
                check = 1
                TextBox2.Text = itm2
                TextBox3.Text = itm3
                TextBox4.Text = itm4
                TextBox5.Text = itm5
                TextBox6.Text = itm6

                itm1 = srl.ReadLine
                itm2 = srl.ReadLine
                itm3 = srl.ReadLine
                itm4 = srl.ReadLine
                itm5 = srl.ReadLine
                itm6 = srl.ReadLine
            Else
                itm1 = srl.ReadLine
                itm2 = srl.ReadLine
                itm3 = srl.ReadLine
                itm4 = srl.ReadLine
                itm5 = srl.ReadLine
                itm6 = srl.ReadLine
            End If
        End While
        If check = 0 Then
            MsgBox("Record Not Found")
        End If

        srl.Close()
        fsl.Close()
    End Sub
 
it reads 6 lines from "E:\info.txt"
while the first line (itm1) is not nothing, it checks if itm1 = textbox1.text
if it is, it puts the other itm's in the other textboxes
if it isn't (itm1 <> textbox1.text), it reads the next 6 lines, then loops
 
Back
Top