QuestionCheck my code please.

Posts 112 of 12 · Page 1 of 1
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:
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)
a chat with ftp? it will lag i guess...?

To create a chat use Sockets
It lags every 30 seconds because the timer and every time you refresh for about 2 second then thats it. . .and thats when its trying to connect to a imposable connection

I just need to know if it'll work.
Quote Originally Posted by Web-Designer View Post
It lags every 30 seconds because the timer and every time you refresh for about 2 second then thats it. . .and thats when its trying to connect to a imposable connection

I just need to know if it'll work.
It will work, but with extremely poor speed !!
Two things:
1. Speed : Refreshing once every 30 seconds is just impossible for chatting.
2. Security : I could hack that (as anyone could) and destroy / manipulate your chat log and future chats however I want.

Solution: Use a server sided system + HTTP POST for content. You should validate user submissons before adding them to your database (which could be a simple plain text file when you start off)
Use TCP plox -.-"
Quote Originally Posted by Blubb1337 View Post
Use TCP plox -.-"
TCP is not feasible for most people who want to run it on a shared web server - you need shell access to install a server. HTTP will be fine for most people.
Quote Originally Posted by freedompeace View Post
TCP is not feasible for most people who want to run it on a shared web server - you need shell access to install a server. HTTP will be fine for most people.
Is there any system on the planet that's running windows OS and doesn't support sockets chat ? If so, let me know !!
Quote Originally Posted by Hassan View Post


Is there any system on the planet that's running windows OS and doesn't support sockets chat ? If so, let me know !!
My laptop is not connected to the internet =( That and I removed winsock by accident
Quote Originally Posted by Hell_Demon View Post
My laptop is not connected to the internet =( That and I removed winsock by accident
Hurrayyy, we found a new kind of noob on the planet...lulz

Quote Originally Posted by Hassan View Post


Is there any system on the planet that's running windows OS and doesn't support sockets chat ? If so, let me know !!
Windows Phone 7 is a Windows OS that does not support sockets.

pwn'd ! ahahah xD

(It's true though)
Stay on topic
Posts 112 of 12 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?