Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class frmDirectory
- Public directory As String
- Public theDirect As String
- Private Sub frmDirectory_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- My.Settings.Directory = directory
- theDirect = txtDirectory.Text
- Login.Show()
- End Sub
- Private Sub frmDirectory_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- directory = My.Settings.Directory
- If My.Settings.Directory = "" Or My.Settings.Directory = "0" Then
- If My.Computer.FileSystem.FileExists("D:\test.txt") Then
- txtDirectory.Text = "D:\test.txt"
- End If
- Else
- If My.Computer.FileSystem.FileExists(My.Settings.Directory) Then
- txtDirectory.Text = directory
- Else
- txtDirectory.Text = ""
- End If
- theDirect = txtDirectory.Text
- End If
- End Sub
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- Dim myIPaddress As String
- Dim tmpHostName As String = System.Net.Dns.GetHostName()
- myIPaddress = System.Net.Dns.GetHostByName(tmpHostName).AddressList(0).ToString()
- If My.Computer.FileSystem.FileExists(txtDirectory.Text) Then
- If txtDirectory.Text.Contains(".txt") Then
- directory = txtDirectory.Text
- My.Settings.Directory = txtDirectory.Text
- MsgBox("Directory set to: " & directory, MsgBoxStyle.Information, "Success")
- Login.Show()
- Me.Close()
- Else
- MsgBox("The directory must be a .txt file", MsgBoxStyle.Critical, "Error")
- txtDirectory.Text = My.Settings.Directory
- End If
- Else
- MsgBox("The file directory you have entered was not found", MsgBoxStyle.Critical, "Error")
- txtDirectory.Text = My.Settings.Directory
- End If
- If My.Computer.FileSystem.ReadAllText(My.Settings.Directory).Contains(myIPaddress) Then
- Else
- frmCreate.Show()
- Me.Close()
- Login.Close()
- End If
- End Sub
- Private Sub txtDirectory_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles txtDirectory.KeyDown
- If e.KeyCode = Keys.Enter Then
- Button1.PerformClick()
- End If
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- Dim SFD As New SaveFileDialog
- Dim sv As String
- SFD.Filter = "(*.txt)|*.txt"
- SFD.ShowDialog()
- sv = SFD.FileName
- Dim sw As New StreamWriter(sv)
- sw.Write("")
- sw.Close()
- txtDirectory.Text = SFD.FileName
- End Sub
- Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
- Dim ofd As New OpenFileDialog
- ofd.Filter = "(*.txt)|*.txt"
- ofd.ShowDialog()
- txtDirectory.Text = ofd.FileName
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement