Type Mismatch Error

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,038
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Consider this line of code in a standard module:
Code:
pgrm_st = bkg_date + CDbl(frmservice.Controls("tb_s" & index & "_lwr").Value)

pgrm_st is publically declared as Double and is supposed to hold the value of a date and a time (bkg_date & value of textbox tb_s1_lwr.
frmservice is declared an object referring to the opyn userform object. Index =1, so the texbox control = tb_s1_lwr which as a text value of "10:00A"
Booking date = 44024.

Instead of getting an anctipated value of 44024.4316666667, I'm getting a Type Mismatch error.

Thoughts?
 
Last edited by a moderator:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,038
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Appears it did not like the tb value of "10:00A"
I fixed it up with this:
Code:
        s = frmservice.Controls("tb_s" & index & "_lwr").Value
        If Right(s, 1) = "A" Then pre = " AM"
        If Right(s, 1) = "P" Then pre = " PM"
        numval = Left(s, len(s) - 1)
        prgm_st = CDbl(bkg_date + CDate(numval & pre))
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,235
Messages
5,768,951
Members
425,507
Latest member
AndreaWorkPlace

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
Top