Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Names
- HarryS1
- HarryS2
- HarryS3
- Dim text As String = File.ReadAllText("names.txt")
- Dim index As Integer = text.IndexOf(HarryS)
- If index >= 0 Then
- MessageBox.Show("Name Found")
- Else
- MessageBox.Show("Name not found")
- End If
- Try
- Dim text As String = vbCrLf & System.IO.File.ReadAllText("C:Tempnames.txt") & vbCrLf
- Dim index As Integer = text.IndexOf(vbCrLf & "HarryS2" & vbCrLf)
- If index >= 0 Then
- MessageBox.Show("Name Found")
- Else
- MessageBox.Show("Name not found")
- End If
- Catch ex As Exception
- MessageBox.Show("Exception found!" & vbCrLf & ex.ToString)
- End Try
- Try
- FileOpen(1, "FilePath", OpenMode.Input, OpenAccess.Read, OpenShare.LockWrite)
- Dim found As Boolean = False
- While (EOF(1) = 0)
- Dim readData As String = LineInput(1)
- If readData = "HarryS" Then
- found = True
- Exit While
- End If
- End While
- If found = True Then
- MsgBox("Found")
- Else
- MsgBox("Not found")
- End If
- Catch ex As Exception
- MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
- Finally
- FileClose(1)
- End Try
- Imports System
- Imports System.IO
- Imports System.Text
- Public Class Test
- Public Shared Sub Main()
- Dim path As String = "c:tempMyTest.txt"
- Try
- If File.Exists(path) Then
- File.Delete(path)
- End If
- Dim sw As StreamWriter = New StreamWriter(path)
- sw.WriteLine("This")
- sw.WriteLine("is some text")
- sw.WriteLine("to test")
- sw.WriteLine("Reading")
- sw.Close()
- Dim sr As StreamReader = New StreamReader(path)
- Do While sr.Peek() >= 0
- Console.WriteLine(sr.ReadLine())
- Loop
- sr.Close()
- Catch e As Exception
- Console.WriteLine("The process failed: {0}", e.ToString())
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement