locked
loggin

    Question

  • I created a loggin form and dont know how to do the loggin databases so i figured id code the loggins. but it doesnt work can u help me with this or say how to do the databases?

     

    If (UsernameTextBox.Text = "Loggin" & PasswordTextBox.Text = "Password") Then

    Dim openform1 As Form1 = New Form1

    openform1.ShowDialog()

    End If

    End Sub

    Thursday, May 11, 2006 10:28 PM

Answers

  •  Its really simple

    Use

    If (UsernameTextBox.Text = "Loggin" AND PasswordTextBox.Text = "Password") Then

    and not

    If (UsernameTextBox.Text = "Loggin" & PasswordTextBox.Text = "Password") Then


    Use of the & in this scenario is wrong & is string contatenation and therefor I would expecte something like an invalid cast exception.

    Otherwise your doing a string comparison which will give you a true of false

    UsernameTextBox.Text = "Loggin"   = True / False

    PasswordTextBox.Text = "Password")  = True / False

    and then trying to do string concatenation on two booleans.   Which is invalid.

    Friday, May 12, 2006 1:43 AM

All replies

  • Hi.

    I'm not sure what & does in VB, I thought you needed to use 'and'.  However, overall, this looks to me like I'd expect it to work.  Have you stepped through the debugger to see what's going wrong ? What is happening ?

    www.codeproject.com has lots of articles, you'd find info there on how to connect to a database.  This is obviously not secure, anyone can use reflector to find out what the username/password are.

     

    Thursday, May 11, 2006 10:34 PM
    Moderator
  • well you see.

     

    The debugger says the code is fine unti you enter the loggin form, my program starts on a Form1, then you cilck a button to go to Loginform and then it stops responding.

    Thursday, May 11, 2006 10:35 PM
  • The debugger does not tell you the code is fine.  You set a break point with F9 and if you're running in debug mode, the code stops there and you can go through one step at a time.  If your app is freezing, it seems likely to me that the other form is being created, and causing the problem somehow.

    Please set a breakpoint and step through to work out if thise code is executing, and on what line it freezes.

     

    Thursday, May 11, 2006 10:48 PM
    Moderator
  • If (UsernameTextBox.Text = "Loggin" & PasswordTextBox.Text = "Password") Then

     

    has the error on it

    Thursday, May 11, 2006 10:54 PM
  •  Its really simple

    Use

    If (UsernameTextBox.Text = "Loggin" AND PasswordTextBox.Text = "Password") Then

    and not

    If (UsernameTextBox.Text = "Loggin" & PasswordTextBox.Text = "Password") Then


    Use of the & in this scenario is wrong & is string contatenation and therefor I would expecte something like an invalid cast exception.

    Otherwise your doing a string comparison which will give you a true of false

    UsernameTextBox.Text = "Loggin"   = True / False

    PasswordTextBox.Text = "Password")  = True / False

    and then trying to do string concatenation on two booleans.   Which is invalid.

    Friday, May 12, 2006 1:43 AM
  • Ok well i set the code to

    If (UsernameTextBox.Text = "Loggin" And PasswordTextBox.Text = "Password") Then

                                                            ^

                                                         with and

    and then i made it to where if UsernameTextBox.Text = "Loggin" aswell as the password = "password" then it would MsgBox("loggin correct"), it doesnt bring up an error or anything but it doesnt display the text instead it just exits The loggin form

     

    Does the fact that

    Private Sub Login_Load //its in here

    matter?

    Friday, May 12, 2006 1:56 AM
  • sweet, nvm i figgured it out this time actually, i have to have it in the sub

    Private Sub OK_Click()

     

    Friday, May 12, 2006 2:01 AM
  • thx for the help though, i couldnt haev figured it out without the And thing, thx again spotty =P
    Friday, May 12, 2006 2:02 AM
  • Glad you got it sorted....

    Try to include where your calling the code from as well.   ie. If its in a form load include the whole sub..... end sub.   That way we'll also be able to see where your trying to call it from which is often part of the problem.

    But glad your sorted on this....

     

    Friday, May 12, 2006 2:58 AM
  • as you learn more you can start to look at code and figure out the problem easier i guess you could say
    Friday, May 12, 2006 4:26 AM
  • Thats true - the more you use it the more you know where to look for answers as well.

     

    Friday, May 12, 2006 4:32 AM
  • Probly gona make my own music player, but i have a few questions, can you play .mp3s and not just wavs and is this a valid code for input?

     

    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    My.Computer.Audio.Play("C:/Program Files/BA-92/Music" & TextBox3.Text)

    End Sub

     

    Friday, May 12, 2006 4:43 AM
  • This statement My.Computer.Audio.Play will only play wav files.

    In order to play mp3's there are a number of ways - one would be to use the Windows Media Player object.

    Do a quick search on this forum or the VB General Forum on MP3 and you'll see a number of solutions to the problem.

     http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=54447&SiteID=1

    Friday, May 12, 2006 4:58 AM
  • does the express version have this?
    Friday, May 12, 2006 5:02 AM
  • nvm i got it =P, once again i didnt look at it enough
    Friday, May 12, 2006 5:04 AM