LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default textboxes and datatypes

I've used a class module to define my object with various properties and methods which interact with each other. I then populate a collection (database) with my objects (records). I have a userform for adding a new record, or calling up an existing record. The fields (textboxes) on the form correspond to the properties of my class module.

In the class module I have written all the code for the interaction between the properties, and I want exactly the same rules to apply to the userform. I've been trying to accomplish this by using the same code, but my problem is that textboxes hold text, and the various properties of my class module can hold dates, currency, etc. There's no "type" property for my textboxes.

Can I tell VBA what type of data is stored in each of the textboxes in my form so that my calculations will work?
and / or
Is there another way around this that I'm missing?

Thanks very much for any help
Rob


'I populate my collection
Set DataBase = New Collection
For i = 2 To LastRow(3, DataSheet.Name, ThisWorkbook.Name)
Set Record = New MyClass
Record.OrderNumber = DataSheet.Cells(i, 3)
DataBase.Add Record
Next


'when I change the OrderNumberTextbox on my form:
Private Sub OrderNumber_Change()
Set ThisOrder = New MyClass
With ThisOrder
.OrderNumber = OrderNumber
'If the order number already exists in my collection the other properties are set
'...then I fill in the textboxes
OrderDate = .OrderDate
DeliveryDate = .DeliveryDate
Supplier = .Supplier
Description = .Description
OrderValue = .OrderValue
InvoiceValue = .InvoiceValue
'when i try to do a calculation, eg.
if OrderDate = DeliveryDate then CalculationTextBox = OrderValue - InvoiceValue
'everything goes wrong because it thinks everything is text
End With


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textboxes SAL Excel Discussion (Misc queries) 2 July 13th 07 12:24 AM
Arrays/Functions/Different datatypes in a formula? Jess Excel Worksheet Functions 3 November 13th 06 10:15 AM
tab between several textboxes Kim Excel Worksheet Functions 0 May 9th 05 04:08 PM
VBA has "lost" some datatypes MWE[_2_] Excel Programming 3 December 31st 03 06:02 PM
Excel Textboxes Cade09 Excel Programming 1 November 21st 03 05:17 PM


All times are GMT +1. The time now is 02:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"