[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Running a Form From Visual Basic

Posted on 1999-01-24
5
Medium Priority
?
181 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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