Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

How do I convert a string to a decimal digit?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Guus van Waardenburg - 04 May 2006 12:45 GMT
Good day,

I have two Userforms.

You can see the first one as the parentform so to speak and the second one
as the subform.

Now what I want to do when I'm finished with te subform is: sum up a digit
in the subform with a digit on the parentform and then replace the last digit
with the outcome. But when I try this with a simple 'formula' like:
   Dim i As Double
         i = frmParent.lblTotal.Caption + lblPremium.Caption
   frmParent.lblTotal.Caption = i

VBA treats my outcome as a string. This means that when the caption was 100
and de new outcome would be 10 then it doesn't say 110 but 10010!!!

Now I know I have to use something like i = CDbl(frmParent.lblTotal.Caption
+ etc.

But I cant get it to work, can somebody help???
Greg Maxey - 04 May 2006 13:01 GMT
Try something like:

Sub Test()
Dim ptest1 As String
Dim ptest2 As String
Dim i As Long
ptest1 = 100
ptest2 = 10
i = CDbl(ptest1) + CDbl(ptest2)
MsgBox i
End Sub
Guus van Waardenburg - 04 May 2006 14:43 GMT
Yes! Thanks Greg,

Apart from some minor changes this worked great!

> Try something like:
>
[quoted text clipped - 7 lines]
> MsgBox i
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.