Thank you for your replies.
With .g1 I get "method or data member not found".
I have one userform for input and output at the same time.
And the problem is that when I use that code for userorm
Option Explicit
Private Sub CommandButton1_Click()
addr = Form2.RefEdit1.Value
n1 = Form2.TextBox1.Value
s2 = Form2.TextBox6.Value
TextBox2 = g1
TextBox3 = g2
TextBox4 = g3
TextBox5 = g4
Debug.Print s2
'Unload Me
End Sub
and for a module
Public g1 As Double, g2 As Double, g3 As Double, g4 As Double
.........
Sub Sim()
Form2.Show
Dim rng As Range, s As Integer, r As Double, bm As Double, sum(), s1 As Integer
......
Set rng = Range(addr)
Set frm = Form2
If Not rng Is Nothing Then
a1 = Application.Transpose(rng.Value2)
End If
n = n1
s1 = s2
.........
With frm
g1 = 1
g2 = 1
g3 = 1
g4 = 1
'.Show
End With
End Sub
I get the results from a previous start of sub sim. In other word, the first start gives 0,0,0,0 and the second right answer 1,1,1,1.