I've got that. that should be displayed after log on ( it can be rewrite with use IF statement)

Private Sub cmdLogon_Click()
Dim age As Integer

age = InputBox("please enter your age")
Select Case age
Case Is >= 18
MsgBox "you are" & " " & age & ", let's go to the pub"
Case Is < 18
MsgBox "you are" & " " & age & ", you can't drink!"
Case Is < 17
MsgBox "you are" & " " & age & ", you can't drink!"
End Select

End Sub

and i have task to do with that.
1. design, write and test program that requires the user to enter a username AND password. On successful login the program should dispal the message 'welcome <username>' Invalid logins will results in the message 'sorry access denied, please check your username and password and try again'

2. Alter the calculator program so that it displays an error message if the user enters any values below 0 or above 99

can u help me?

i've got something like that:

Private Sub Command1_Click()

Dim username As String
Dim password As String
Dim age As String

username = txtUser.Text
password = txtPass.Text
If username = dawid And password = qwerty Then
MsgBox ("Welcome," & " " & username)
Else
MsgBox (" Sorry, access denied, please check your username and password and try again")
End If

End Sub

Go for the following -

Create a databse with Login Details, Username, Password and Login Age.

This can be done with Access, sql, mysql etc. with the correct connection string.

Either create your app with a start up screen where the data is empty as in -

If rsLogin.BOF OR rsLogin.EOF = True then
   msgbox "First Time Start Up. Enter User Data..."
       ELSE
   IF txtUsername = rsLogin!UserName Then
       frmMain.Show
       Unload Me
           Else
       msgbox "Login Failed....."
   End If
End If

Hope this puts you on the correct path to solve your problem....

no, i have to do without database. I already have login form code. and now i dont know how to put content after log on (calculator).

Private Sub Command1_Click()

Dim username As String
Dim password As String
Dim age As String

username = txtUser.Text
password = txtPass.Text
If username = "dawid" And password = "qwerty" Then
MsgBox ("Welcome," & " " & username)
Else
MsgBox (" Sorry, access denied, please check your username and password and try again")
End If

End Sub

and i have calculator:

Private Sub Command1_Click()
Dim age As Integer

age = txtAge.Text
If age >= 18 Then
MsgBox "You are " & age & ", let's go to the pub!"
Else
MsgBox "You are " & age & ", you can't drink!"
End If
End Sub

i dont know hot to put that together

Private Sub Command1_Click()

Dim username As String
Dim password As String

username = Trim(txtUser.Text)
password = Trim(txtPass.Text)
If username = "dawid" And password = "qwerty" Then
    MsgBox ("Welcome," & " " & username)
    Dim age As Integer

    age = Val(txtAge.Text)
    If age >= 18 Then
        MsgBox "You are " & age & ", let's go to the pub!"
    Else
        MsgBox "You are " & age & ", you can't drink!"
    End If
Else
    MsgBox (" Sorry, access denied, please check your username and password and try again")
End If

End Sub

How about this ?

Dim age As String

don't mind. why you use it plz.....

don't mind. why you use it plz.....

Sorry... I was in a hurry.... Didn't looked that.... :D

I was just combining the codes that were already posted....
Thanks for pointing out...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.