2

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?

7
  • Is this a userform in Excel or a form within Access? Commented Aug 12, 2015 at 7:40
  • 1
    Are you trying to retrieve number from password.output.Caption? Because Val function returns the numbers contained in string, else it returns 0. Commented Aug 12, 2015 at 7:43
  • Actually I wanna retrieve string . Any ideas how could I do it? I am new to vba Commented Aug 12, 2015 at 7:43
  • Try this. Dim value = password.output.Caption Commented Aug 12, 2015 at 7:45
  • Nope this does not works for me Commented Aug 12, 2015 at 7:49

2 Answers 2

3

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

Try this.

 Dim value As String
 value = password.output.Caption
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments