English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

if frmLogin is a form with two text boxes, one for entering a login name and the other for a password, and frmMain is a form that will display frmLogin and use the data the user enters. Describe the preferred method for getting the data to frmMain.

2007-01-09 08:16:45 · 4 answers · asked by bhs00 2 in Computers & Internet Programming & Design

4 answers

Is the VB6? If so, here's what I do:

(1) First, I make a login/logon form with variables that you want to have access to at the top before and functions.

Private MyReturnVal As Integer
Private sPassword as String
Private sUserName as String

(2) The first sub within the form I call ShowForm(). If you only have one value you want to return, then you can do it as the return value of this function.

Public Function ShowForm( Any Parameters ) as Integer


Me.Show vbModal (or vbModeless)
ShowForm = MyReturnValue
End Function

Set the sPassword and sUserName values in their appropriate functions.

(3) You would call it from frmMain like this:

Dim dlgLogin as frmLogin


iReturnValue = dlgLogin .ShowForm
sMyPassword = dlgLogin .sPassword
sMyUserName = dlgLogin .sUserName

Hope that helps!

2007-01-09 09:12:30 · answer #1 · answered by Anonymous · 0 0

Use Public variables in the login form, and hide (don't unload) the login form:

Option Explicit
Public g_strUsername as String
Public g_strPassword as string

==========================
Private Sub cmdLogin_Click()
g_strUsername=txtUsername.text
g_strPassword = txtPassword.text
Hide Me
Show frmMain
End Sub
================================

in the Form_Load() procedure of frmMain:

Private Sub Form_Load
Print g_strUsername
Print g_strPassword
...
End Sub

2007-01-09 09:13:10 · answer #2 · answered by Richard H 7 · 0 1

My vb is tremendously rusty, however heres how I might do it. dim CashAmt as Integer CashAmt = lblCashamount.Caption (probably .textual content, cant recall, been 6 years because i wrote a line of VB) now for your different variety.. lblCashCount.Caption = CashAmt Idealy you might love to make each captions same the variable that you're storing the coins integer in. Good success.

2016-09-03 19:07:47 · answer #3 · answered by faella 4 · 0 0

declare variables in frmMain and assign the values from frmLogin

Dim strName, strPassword as String

strName = frmLogin.txtName
strPassword = frmLogin.txtPassword

2007-01-09 08:41:58 · answer #4 · answered by rod 6 · 0 0

fedest.com, questions and answers