Novahq.net Forum

Novahq.net Forum (https://novahq.net/forum/index.php)
-   Web design and Programming (https://novahq.net/forum/forumdisplay.php?f=32)
-   -   Blades Chat Program (https://novahq.net/forum/showthread.php?t=52310)

~BLÃÐE~ 01-27-2021 04:33 PM

Blades Chat Program
 
Ok so i wanted to make an app/program sort of like ICQ for those that remember it.
A simple chat program made in VB that works off my web hosting service.

I finally found a tutorial sort of like what i wanted.
The guy that did the video has moved on and didn't reply to emails, i found the source code which is slightly different to the video but mostly there with the missing bits, well most of them lol.

I was hoping with help from some of you we might be able to get it working properly, never know might start a new community chat service.

Software: I'm using VB 2017

Video Tutorial: The first 4 mins shows a working version
https://www.youtube.com/watch?v=6mUCZq6pyvo

If anyone is interested in the project i can send a link to all the files.

So far....
I have the app complete but getting lots of little issues, it needs finishing and a little polish.

I can register and login no worries
When i Edit Profile which puts the details in, name, mobile, email, pass change. I get the error user already exists (see code example 1)

Or i changed to another bit of code to do the same thing i get another issue of that users over rights all other users in the DB, so if i had 3 users Bob, Bill, Merry and edited Bob, there would be 3 entries of Bob and no Marry or Bill.
(see code Example 2)


Example 1

Code:

Imports MySql.Data.MySqlClient

Public Class frmEditProfile

    Private Sub frmEditProfile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.Open()

        txtName.Text = My.Settings.FirstName
        txtEmail.Text = My.Settings.Email
        txtMobile.Text = My.Settings.Tel
        txtUsername.Text = My.Settings.Username
    End Sub

    Private Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click
        Dim cmdread As New MySqlCommand("SELECT * FROM users", con)
        Dim datareader As MySqlDataReader
        Try
            datareader = cmdread.ExecuteReader
            While datareader.Read()
                If datareader(1).ToString = txtUsername.Text And Not My.Settings.Username = txtUsername.Text Then
                    MsgBox("Username already exists.", MsgBoxStyle.Exclamation, "Username Error")
                    datareader.Close()
                    Exit Sub
                End If
                If datareader(3).ToString = txtEmail.Text And Not My.Settings.Email = txtEmail.Text Then
                    MsgBox("Email already exists.", MsgBoxStyle.Exclamation, "Email Error")
                    datareader.Close()
                    Exit Sub
                End If
                If datareader(6).ToString = txtMobile.Text And Not My.Settings.Tel = txtMobile.Text Then
                    MsgBox("Mobile number already exists.", MsgBoxStyle.Exclamation, "Mobile No. Error")
                    datareader.Close()
                    Exit Sub
                End If
            End While
            datareader.Close()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Database Error")
        End Try
    End Sub

    Private Sub frmEditProfile_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        con.Close()
    End Sub

End Class

Example 2

Code:

Public Class EditProfile
#Region "declare"
    Dim mycmd As New MySqlCommand
    Dim myconnection As New DTConnection
    Dim objreader As MySqlDataReader
#End Region


    Private Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click
        mycmd.Connection = myconnection.open
        mycmd.CommandText = "update users set username='" & txtUsername.Text & "',email='" & txtEmail.Text & "',password='" & txtPassword.Text & "', name='" & txtName.Text & "', mobile='" & txtMobile.Text & "' "
        mycmd.ExecuteNonQuery()
        myconnection.close()
        MsgBox("Data changed !!", MsgBoxStyle.Information, "Notice..")

    End Sub

    Private Sub EditProfile_Load(sender As Object, e As EventArgs)
        txtName.Text = My.Settings.FirstName
        txtEmail.Text = My.Settings.Email
        txtMobile.Text = My.Settings.Tel
        txtUsername.Text = My.Settings.Username
    End Sub

    Private Sub EditProfile_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class


Stephen 01-27-2021 04:56 PM

Very interesting, I wish you luck with your project. That is way out of my lane in regards to experience but I am sure some others here would be a good fit.

Scott 01-28-2021 08:09 AM

Unfortunately I don't know much VB. Any reason you decided to go with VB instead of something like c#?

I think selecting the entire user database and looping through it is going to be a problem if you have many users. I also don't see if you're assigning a unique userid that isn't the username/email to the profile.

You're query could look something like this:
Code:

SELECT * FROM users WHERE username='new username' AND userid != 'current userid'
If that query comes back positive, the username requested is already assigned to another user.

For whatever reason, the comparison operators in VB don't compute in my head but I think the username compare line needs to be something like this:
Code:

If datareader(1).ToString = txtUsername.Text And Not My.Settings.Username = datareader(1).ToString Then

~BLÃÐE~ 01-29-2021 01:17 AM

Quote:

Originally Posted by Scott (Post 397881)
Unfortunately I don't know much VB. Any reason you decided to go with VB instead of something like c#?

I only went that way as the tutorial was written in VB
Should i be looking to change it all over to C#?

~BLÃÐE~ 01-29-2021 02:56 AM

Ok found another tutorial in C#
i will put it together and see how i go with this one and get back to you. :P

Scott 01-30-2021 09:15 AM

I would use something more widely supported and modern like c# but it's totally up to you.

--BulletMagnet-- 01-30-2021 10:43 AM

C# is superior in every way. MS is phasing out VB.

~BLÃÐE~ 01-31-2021 03:38 PM

1 Attachment(s)
Thanks for the feedback.....
I see most VB tuts are old and outdated but i thought it might be the way to go.

I have started to redo it in C#
The Registration and Login are done as is the DB info.

I'm still learning so I'm expecting to hit walls and have issues.
Next i will setup a chat page and see if i can send a message.

~BLÃÐE~ 02-03-2021 01:24 AM

Well I'm starting to get somewhere with it, here is a short clip of what i have so far...

I managed to do the reg, login, change the font size color and background
I'm trying to figure a few thing out but a few more hours of searching and i hope to sort them out

It has a long ways to go but for someone without knowledge of coding or prier learning i think I'm doing ok



I do have a question if anyone might know...
I want to add a unique member id number starting a 1000000, so e.g.
Scott is the user, membership id is 1000468.
Users can search for id number to find user and add as a friend

p.s. sorry for the crap recording, i just grabbed the first thing that records and made a quick clip, i will make a better one later as i progress

Scott 02-03-2021 08:02 AM

Nice work blade!

If you're using a MySQL database you can start the auto_increment field at 100000000 (make sure it's an unsigned int field). When creating a new account, once you insert the user you can use LAST_INSERT_ID() on the table to find the last id you inserted so you can display it to the user.

IcIshoot 03-21-2021 12:12 PM

Looking good!


All times are GMT -5. The time now is 05:25 AM.

Powered by vBulletin®