Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Newbie TextBox problem - Please help.

Please help me to work this out!!

The code below is from my UserForm3 which is a simple form with
three textboxes, from which I need to gather some variables _for later
use_.

I am testing with gathering the variables ( hostname, UserID and pass )
then
I want to show message boxes showing their values ( on submit - at the
top ).

I'm a real newbie to xlvba and would really appreciate some help
regarding how to
get the values of a textbox "out" of it's own textbox change sub.

Thanks in advance!

Stuart


' On Submit
Sub CommandButton2_Click()
MsgBox hostname
MsgBox UserID
MsgBox pass

End Sub



' Cancel and clear
Sub CommandButton3_Click()
Unload UserForm3
UserForm3.Hide

End Sub

' Enter the hostname
Sub TextBox1_Change()
Dim hostname As String
hostname = TextBox1.Text

End Sub

' Enter the user id
Sub TextBox2_Change()
Dim UserID As String
UserID = TextBox2.Text

End Sub

' Enter the password
Sub TextBox3_Change()
Dim pass As String
pass = TextBox3.Text


End Sub

Private Sub UserForm_Click()

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Newbie TextBox problem - Please help.

This goes in a general module--not behind the userform:

Option Explicit
Public HostName As String
Public UserID As String
Public Pass As String
Sub showTheForm()
UserForm1.Show
MsgBox HostName & vbLf & UserID & vbLf & Pass
End Sub

This goes behind the userform:

Option Explicit
Sub CommandButton3_Click()
HostName = Me.TextBox1.Text
UserID = Me.TextBox2.Text
Pass = Me.TextBox3.Text
Unload Me
End Sub

The variables are declared public, so they're visible to all the procedures.
(Check out scope and visibility in VBA's help.)

The me. stuff refers to the thing that owns the code. In this case it's the
userform.

You'll want to add some validation, too (I would suspect).

krayten wrote:

Please help me to work this out!!

The code below is from my UserForm3 which is a simple form with
three textboxes, from which I need to gather some variables _for later
use_.

I am testing with gathering the variables ( hostname, UserID and pass )
then
I want to show message boxes showing their values ( on submit - at the
top ).

I'm a real newbie to xlvba and would really appreciate some help
regarding how to
get the values of a textbox "out" of it's own textbox change sub.

Thanks in advance!

Stuart

' On Submit
Sub CommandButton2_Click()
MsgBox hostname
MsgBox UserID
MsgBox pass

End Sub

' Cancel and clear
Sub CommandButton3_Click()
Unload UserForm3
UserForm3.Hide

End Sub

' Enter the hostname
Sub TextBox1_Change()
Dim hostname As String
hostname = TextBox1.Text

End Sub

' Enter the user id
Sub TextBox2_Change()
Dim UserID As String
UserID = TextBox2.Text

End Sub

' Enter the password
Sub TextBox3_Change()
Dim pass As String
pass = TextBox3.Text

End Sub

Private Sub UserForm_Click()

End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Problem for Newbie - Please! Terri[_2_] New Users to Excel 4 March 26th 08 09:30 PM
Newbie problem need formula help toddbob Excel Worksheet Functions 3 April 3rd 06 06:24 PM
Newbie problem :( Liosan Excel Programming 6 August 15th 05 02:16 PM
Newbie Problem BuddyB Excel Programming 2 February 16th 05 04:45 AM
newbie userform problem Kevin Excel Programming 1 August 5th 03 12:25 AM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"