View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
filo666 filo666 is offline
external usenet poster
 
Posts: 265
Default Help deffining public variables in userform1

Hi, I have a problem deffining my public variables in my userform, I have
with this problem 3 days and I can't solve it, could you helpme??? I attached
all my coding, the userform1 has 10 textboxes, one button to ADD a
registration (commandbutton1) and other to close the userform when user has
finished to use it (commandbutton2)

In my userform sheet:
Public maestro As String
Public clase1 As String
Public clase2 As String
Public clase3 As String
Public sueldo1 As Integer
Public horas1 As Integer
Public sueldo2 As Integer
Public horas2 As Integer
Public sueldo3 As Integer
Public horas3 As Integer
__________________________________________________ __________________
Private Sub CommandButton1_Click()
Dim b As Integer
maestro = TextBox1
clase1 = TextBox2
clase2 = TextBox3
clase3 = TextBox4
sueldo1 = TextBox5
horas2 = TextBox6
sueldo2 = TextBox7
horas3 = TextBox8
sueldo3 = TextBox9
horas3 = TextBox10

If maestro < "" Or clase1 < "" Or clase2 < 0 Or clase3 < 0 Then
agregarmaestro
Else
b = MsgBox("Debe de haber por lo menos los datos de un solo maestro, por
favor proporcionalos", vbOKCancel, "Error, falta informaciĆ³n")
If b = 2 Then
End
End If
End If
End Sub
__________________________________________________ ________________
Private Sub CommandButton2_Click()
End
End Sub

In my Module1 sheet:


Sub agregarmaestro()
a = ActiveSheet.Range("A1", Range("A65535").End(xlUp)).Count
Rows(a + 2).Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Range(Cells(a + 3, 1), Cells(a + 5, 1)).Select
With Selection
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range(Cells(a + 3, 5), Cells(a + 5, 5)).Select
With Selection
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
UserForm1.Show
Cells(a + 3, 1) = TextBox1
Cells(a + 3, 2) = TextBox2
Cells(a + 3, 3) = TextBox3
Cells(a + 3, 4) = TextBox4
Cells(a + 4, 2) = TextBox5
Cells(a + 4, 3) = TextBox6
Cells(a + 4, 4) = TextBox7
Cells(a + 5, 2) = TextBox8
Cells(a + 5, 3) = TextBox9
Cells(a + 5, 4) = TextBox10
Cells(a + 3, 5).Formula = "=" & Cells(a + 3, 3).Address & "*" & Cells(a + 3,
4).Address & "+" & Cells(a + 4, 3).Address & "*" & Cells(a + 4, 4).Address &
"+" & Cells(a + 3, 3).Address & "*" & Cells(a + 3, 4).Address & "+" & Cells(a
+ 5, 3).Address & "*" & Cells(a + 5, 4).Address

End Sub

Why I cant use my variables in agregarmaestro macro