Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a sheet1 with a lot of numbers and Text, in the module to this sheet i
have a VB code. Depending of what choices the user makes a new form appears. The form has 3 CmdButtons, called Ok, Next, Cancel. It's like this: If ActiveSheet.Range("e" & EnviromentRow).Value="b6" then Beep Load FrmNewInput FrmNewInput.Show The form code is like this: (The code for the Ok button) Private Sub CmdOk_Click() ''missing something'''' Me.Hide End Sub ''''And then it should "go back" to the module and something like this: If FrmNewInput.CmdCancel = True Then '''''If the user press the cancel button Exit Sub ElseIf FrmNewInput.CmdOk = True Then msgbox Else FrmNewInput.CmdNext = True then msgbox End If This is not correct i know that, but what is wrong? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() for more control use a variable of class frmNewInput similar to.. 'in a module Dim uf1 As UserForm1 'use a module level variable. Sub FormLoader() If uf1 Is Nothing Then Set uf1 = New UserForm1 End If uf1.Show MsgBox uf1.lngExit & vbLf & uf1.TextBox1 & vbLf & uf1.TextBox2 if uf1.lngExit = -1 then set uf1 = nothing End Sub 'in a form of class UserForm1 'holds 2 textboxes and 2 commandbuttons Option Explicit Public lngExit As Long Private Sub CommandButton1_Click() lngExit = 1 Me.Hide End Sub Private Sub CommandButton2_Click() lngExit = -1 Unload Me End Sub Private Sub UserForm_Initialize() Me.TextBox1 = "initial value" Me.TextBox2 = "initial value" End Sub HTH.. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Michael wrote : I have a sheet1 with a lot of numbers and Text, in the module to this sheet i have a VB code. Depending of what choices the user makes a new form appears. The form has 3 CmdButtons, called Ok, Next, Cancel. It's like this: If ActiveSheet.Range("e" & EnviromentRow).Value="b6" then Beep Load FrmNewInput FrmNewInput.Show The form code is like this: (The code for the Ok button) Private Sub CmdOk_Click() ''missing something'''' Me.Hide End Sub ''''And then it should "go back" to the module and something like this: If FrmNewInput.CmdCancel = True Then '''''If the user press the cancel button Exit Sub ElseIf FrmNewInput.CmdOk = True Then msgbox Else FrmNewInput.CmdNext = True then msgbox End If This is not correct i know that, but what is wrong? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Have a look at this: Code ------------------- If ActiveSheet.Range("e" & EnviromentRow).Address="$B$6" then '* I've put address here but if the value is B6 then put it back Beep Load FrmNewInput FrmNewInput.Show End If Select Case FrmNewInput.Button_Code Case FrmNewInput.Cancel Code here for canceling Case FrmNewInput.Ok Code here for ok button Case FrmNewInput.CmdNext Code here for next End Select ------------------- In your form at module level: Code ------------------- Public Const Cancel = 1 Public Const Ok = 2 Public Const CmdNext = 3 '* Public Button_Code as Integer Private Sub CmdOk_Click() Button_Code = Ok Me.Hide End Sub ------------------- Regards Ric -- Rich_ ----------------------------------------------------------------------- Rich_z's Profile: http://www.excelforum.com/member.php...fo&userid=2473 View this thread: http://www.excelforum.com/showthread.php?threadid=38426 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks.
It worked like i hoped. Thank you again:-) -- Nil Satis Nisi Optimum "keepITcool" wrote: for more control use a variable of class frmNewInput similar to.. 'in a module Dim uf1 As UserForm1 'use a module level variable. Sub FormLoader() If uf1 Is Nothing Then Set uf1 = New UserForm1 End If uf1.Show MsgBox uf1.lngExit & vbLf & uf1.TextBox1 & vbLf & uf1.TextBox2 if uf1.lngExit = -1 then set uf1 = nothing End Sub 'in a form of class UserForm1 'holds 2 textboxes and 2 commandbuttons Option Explicit Public lngExit As Long Private Sub CommandButton1_Click() lngExit = 1 Me.Hide End Sub Private Sub CommandButton2_Click() lngExit = -1 Unload Me End Sub Private Sub UserForm_Initialize() Me.TextBox1 = "initial value" Me.TextBox2 = "initial value" End Sub HTH.. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Michael wrote : I have a sheet1 with a lot of numbers and Text, in the module to this sheet i have a VB code. Depending of what choices the user makes a new form appears. The form has 3 CmdButtons, called Ok, Next, Cancel. It's like this: If ActiveSheet.Range("e" & EnviromentRow).Value="b6" then Beep Load FrmNewInput FrmNewInput.Show The form code is like this: (The code for the Ok button) Private Sub CmdOk_Click() ''missing something'''' Me.Hide End Sub ''''And then it should "go back" to the module and something like this: If FrmNewInput.CmdCancel = True Then '''''If the user press the cancel button Exit Sub ElseIf FrmNewInput.CmdOk = True Then msgbox Else FrmNewInput.CmdNext = True then msgbox End If This is not correct i know that, but what is wrong? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how many people are scheduled between... | Excel Worksheet Functions | |||
Need help of you people | Excel Worksheet Functions | |||
Need help of you people | Excel Worksheet Functions | |||
Why do people use SUM() unnecessarily? | Excel Discussion (Misc queries) | |||
new user with easy question? not easy for me | New Users to Excel |