user5024056
user5024056

Reputation:

Getting value from textbox and storing it in a variable in VBA

I am trying to make an application to get the data from the textbox and store it in a variable for further uses thou I am getting value of it as 0 . Anyone can help out?

Dim value As Long

value = Val(password.output.Caption)
game.Caption = value

In the above code password is my form name and output is the name of field from where it shall get data and then later it is changing the value of game field to the value fetched of output and I am getting 0 as the value . What to do guys? Any help will be appreciated

UPDATE

I would actually like to retrieve the string any idea how to do it?

Upvotes: 2

Views: 14016

Answers (2)

R3uK
R3uK

Reputation: 14537

Here you go :

Dim ValuePw As String

ValuePw = Password.output.Value
Password.game.Value = ValuePw

.Caption is used for Labels' content and UserForms' title, for TextBoxes' content, it is .Value

Upvotes: 1

Ashwin K
Ashwin K

Reputation: 230

Val function returns the numbers contained in string, else it returns 0.

Try this.

 Dim value As String
 value = password.output.Caption

Upvotes: 3

Related Questions