Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with CLng and .value

Status
Not open for further replies.

hrg

Programmer
Jan 8, 2009
46
US
I am having problems using the CLng and .Value type in the vba code

I can use these fine if the modules being called hold an integer value like a unique code number.
But when using strings it comes up with error that you can't use CLng or change the .value bit.

As i am not sure what these do could someone please explain what the purpose of the

CLng
.Value

are. If you could also help in which ways i can change them to hold sring values it would
be helpful.

Thank you
 
I very rarely use the .Value property.
Could you post the code please.

Nick
 
Well that's because you can't convert a string to a long number unless is contains nothing but numeric data. CLng tries to convert the string value to a numeric value and doesn't know how to covert alpha characters. Try using the following on strings.

Dim LongValue As Long
If IsNumeric(MyString) Then
LongValue = CLng(MyString)
End If

Steve King Growth follows a healthy professional curiosity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top