In a Module:
Public g1 As Double

Sub Sim()
  g1 = 5
End Sub
In Userform1:
Private Sub CommandButton1_Click()
  Sim
  TextBox1 = g1
End Sub
IF the goal was to load controls before showing, I would:
Sub Sim2()
  Sim
  Load UserForm1
  UserForm1.TextBox1 = g1
  UserForm1.Show
End Sub