?
Solved

Running a Form From Visual Basic

Posted on 1999-01-24
5
Medium Priority
?
178 Views
Last Modified: 2013-11-25
I have a program with two forms in it. The first form will ask for a password. The second form will be the actual program. How do I get the second form (actual program) to run after someone clicks the OK button on the password form. Form2.Show doesn't seem to work. (duh) Make this easy on me as I'm just another lame-o in the crowd.
Thanks
0
Comment
Question by:bendown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
chualk earned 200 total points
ID: 1470451
Just code in the first form
Private function cmdOk_click()
           if text1.text = password then
             form2.show
          else
            msgbox "Invalid password.Try again!"
            text1.setfocus
          end if
end function

0
 

Author Comment

by:bendown
ID: 1470452
Chaulk,
   The code that you suggested is what i have now. It will not run the form though. Here is the code that I have now:
Private Sub cmdOK_Click()
 Dim OldPswd As String
   Dim FName As String
   Dim DefaultPassword
   Dim Msg, Style, Title, Help, Ctxt, Response, MyString
   FName = "c:\windows\pass.pas"
   Open FName For Input As #1   ' Open file.
   Line Input #1, OldPswd
   Close #1

   If txtPassword.Text = OldPswd Then
        OK = True
        Form1.Show
End
       
    Else
       
       MsgBox "Please Enter Correct Password"
        txtPassword.SetFocus
        txtPassword.SelStart = 0
        txtPassword.SelLength = Len(txtPassword.Text)
       
    End If

End Sub

Note: Form2 is my password form. Form1 is the Actual Program.
Please submit any ideas on this to me.
Thanks
0
 

Expert Comment

by:girsu
ID: 1470453
if the END statment after Form1.Show is in your code, you have to remove it, you can use UNLOAD ME to hid the logon form.
0
 

Expert Comment

by:girsu
ID: 1470454
if the END statment after Form1.Show is in your code not dragged by mistake, you have to remove it, you can use UNLOAD ME to hid the logon form.
0
 

Author Comment

by:bendown
ID: 1470455
That did the trick. I did leave out unload me. Girsu, you caught my mistake and Chualk, you had the right idea too. I will give Chualk the points. I will also give Girsu points.
Girsu, Look for:"This Points To Girsu ONLY"
Thanks Again
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question