Textbox .value vs .text recent change?

glfiedler

Board Regular
Joined
Apr 1, 2019
Messages
67
Office Version
  1. 365
Platform
  1. Windows
I use office 365 on a windows 10 system that Microsoft automatically updated yesterday.
An excel project I wrote some 18 years ago is, today, having issues with userform textboxes. This project has worked well for years and the vba errors occurring today have not been modified.
The error is "type mismatch".
Back so many years ago when I was just learning vba programming I was not aware of the slight difference between the "value" and "text" properties of textboxes. I have learned much over the years, thanks to many of you on this forum, and I thought I now had a pretty good idea of the difference.
Here is a typical section of code where the User enters some text along with a dollar amount in a userform textbox. The code basically changes the sign of the dollar amount and places the text and amount in a worksheet.
VBA Code:
With Checking.Range("iDiscoverDate")
            .Offset(blank, 0).Value = PurchaseFM.ActionDate.Text
            .Offset(blank, 1).Value = PurchaseFM.PurDescription.Text
            .Offset(blank, 2).Value = PurchaseFM.Amount.Text * -1
        End With
I changed the code, today, by replacing .text with .value in the "amount" equation:
VBA Code:
With Checking.Range("iDiscoverDate")
            .Offset(blank, 0).Value = PurchaseFM.ActionDate.Text
            .Offset(blank, 1).Value = PurchaseFM.PurDescription.Text
            .Offset(blank, 2).Value = PurchaseFM.Amount.Value * -1
        End With
I still get the mismatch error. Do any of you have any ideas why this is not working?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
In Excel (worksheet formulas), the formula ="Truth"="TRUTH" returns the value TRUE.
Exactly the value TRUE

The worksheet formula (using the Excel's EXACT function) =EXACT("Truth"="TRUTH") returns the value FALSE.
 
Upvote 0
"We could have all lived with a function =ANYCASE("Truth")=ANYCASE("TRUTH") "

the StrComp function?

Well, nevermind. You guys are talking about worksheet functions.
 
Upvote 0
VBA is different. On a worksheet, = is a case insensitive comparison. In VBA = is case sensitive (depending on the use of Option Compare Text). The WorksheetFunction.EXACT is redundant for VBA.
 
Upvote 0
My apologies to all of you. In my original post I said I made no changes. Well, like a politician, that statement was "true", regarding the code that I showed you but not completely "TRUE". I had made some changes to the path to the userform. The details of my error are not relevant here, but it resulted in the "amount.text" being undefined. It may have been "null" it may have been "empty" or something else, I don't know and it does not matter. My workbook is working again!
A note of interest: The code works for my purposes whether I use .text or .value or val(name). Thank you for your comments.
 
Upvote 0
No need for apologies and thanks for your honesty & for letting us know.
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,893
Members
449,194
Latest member
JayEggleton

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