Check my code please.
I haven't got the site yet, gotta wait like 3 weeks, but I'm making the programs I'm putting on the site. . .well this is the ftp chat program I made today
I just wanted some people to go over it and say weather it'll work.
I'm sure once I set all the links up and site up right it'll work just want to double check:
Thanks. (+thanks +rep)
I just wanted some people to go over it and say weather it'll work.I'm sure once I set all the links up and site up right it'll work just want to double check:
Code:
Imports System.Net
Imports System.IO
Public Class Form1
#Region "Settings"
Const strNotice As String = "http://www.Fishy-Designs.com"
#End Region
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim client As New Net.WebClient
client.Credentials = New Net.NetworkCredential(User.Text, Password.Text)
client.UploadString("ftp://Fishy-Designs/Chat/" + ComboBox1.Text, TextBox2.Text & "" & TextBox1.Text & ": " & TextBox3.Text & vbNewLine)
TextBox3.Clear()
Catch ex As Exception
MsgBox("Sorry, This error is being taken care of.", MsgBoxStyle.Critical, "Error!")
End Try
Try
Dim client As New Net.WebClient
client.Credentials = New Net.NetworkCredential(User.Text, Password.Text)
RichTextBox3.Text = client.DownloadString("ftp://Fishy-Designs/Chat/" + ComboBox1.Text)
If RichTextBox3.Text = TextBox2.Text Then
Else : TextBox2.Text = RichTextBox3.Text
End If
Catch ex As Exception
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim client As New Net.WebClient
client.Credentials = New Net.NetworkCredential(User.Text, Password.Text)
RichTextBox3.Text = client.DownloadString("ftp://Fishy-Designs/Chat/" + ComboBox1.Text + ".txt")
If RichTextBox3.Text = TextBox2.Text Then
Else : TextBox2.Text = RichTextBox3.Text
End If
Catch ex As Exception
End Try
End Sub
Private Sub CheckForUpdatesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckForUpdatesToolStripMenuItem.Click
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("update link goes here")
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim newestversion As String = sr.ReadToEnd()
Dim currentversion As String = Application.ProductVersion
If newestversion.Contains(currentversion) Then
MsgBox("You have the newest version!", MsgBoxStyle.Information, "Up To Date :D")
Else
MsgBox("A newer version is available, download at: www.Fishy-Designs.com/Programs/Chat.html", MsgBoxStyle.Information, "Update Available")
End If
End Sub
Private Sub UpdateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateToolStripMenuItem.Click
My.Computer.Network.DownloadFile("http://www.Fishy-Designs.com/downloads/programs/Chat.exe", "C:\Installer.exe")
Process.Start("C:\Installer.exe")
End Sub
Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
Try
Dim client As New Net.WebClient
client.Credentials = New Net.NetworkCredential(User.Text, Password.Text)
RichTextBox3.Text = client.DownloadString("ftp://yourhost/chat.txt")
If RichTextBox3.Text = TextBox2.Text Then
Else : TextBox2.Text = RichTextBox3.Text
End If
Catch ex As Exception
End Try
End Sub
Private Sub TextBox3_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox3.MouseDoubleClick
TextBox3.SelectAll()
End Sub
Private Sub TextBox3_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox3.MouseClick
TextBox3.SelectAll()
End Sub
Private Sub SaveChatHistroyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveChatHistroyToolStripMenuItem.Click
SaveFileDialog1.ShowDialog()
End Sub
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
Dim FileToSaveAs As String = SaveFileDialog1.FileName
Dim objwriter As New System.IO.StreamWriter(FileToSaveAs)
objwriter.Write(TextBox2.Text)
objwriter.Close()
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
Try
Dim request As HttpWebRequest = WebRequest.Create(strNotice)
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
Label3.Text = reader.ReadToEnd()
response.Close()
reader.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
Thanks. (+thanks +rep)


