Combining a Textbox Value (Whole number) & Combobox Value (fraction) to Create A Combined Number Value

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a user form userform1) with a textbox (uf1tb1_wholeqty) in which the user enters a whole number, and a combobox (uf1cbx5_prtqty) from which the user is to select from a choice of four fractions (.00,.25, .50, .75)

With VBA, I need to combine the two to make a number.
eg uf1tb1_wholeqty = 1; uf1cbx5_prtqty = .75; result = 1.75

Here is my code ...
Code:
.Range("G" & trow) = UserForm1.uf1tb1_wholeqty.Value + UserForm1.uf1cbx5_prtqty.Value

Enter the values of the example, the result is 10.75. What I believe is part of the issue is that after the the user selects the fractional quantity and exits, the combobox populates with a leading zero. So although the user selects ".75" from the list, when he exist, the value in the box changes to 0.75.

I tried this too with no change in the result.
Code:
.Range("G" & trow) = CStr(UserForm1.uf1tb1_wholeqty.Value) + CStr(UserForm1.uf1cbx5_prtqty.Value)

How can I best overcome this?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try:
Code:
.Range("G" & trow) = CLng(UserForm1.uf1tb1_wholeqty.Value) + CDbl(UserForm1.uf1cbx5_prtqty.Value)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top