Type Mismatch Error

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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:
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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