Solved

How to clear the values in udt's

Posted on 2014-09-22
7
129 Views
Last Modified: 2014-09-22
I udts that i need to use over with new data
how do i clear the data in the udt's ?


Private Type Info_UDT
  CompanyName  As Byte
  Address      As Byte
  sDate        As Byte
  City         As Byte
  State        As Byte
  Zip          As Byte
  Estimator    As Byte
  BidAmount    As Byte
  sqs          As Byte
  BidMaterial  As Byte
  Email        As Byte
  Bid2Material As Byte
  Bid2Amount   As Byte
  BusYrs       As Byte
  TempNotUsed   As Byte ' for future use if needed
End Type

Private Type Recap_UDT
  CompanyName  As Byte
  Estimator    As Byte
  sDate        As Byte
  BidAmount    As Byte
  BidMaterial  As Byte
  Bid2Amount   As Byte
  Bid2Material As Byte
  sqs          As Byte
  BusYrs       As Byte
   TempNotUsed   As Byte ' for future use if needed
End Type

Private Type Phone_UDT
  Cell      As String
  Office    As String
  Emergency As String
  Fax       As String
  Owner     As String
  LasrRow   As String
  TempNotUsed   As String ' for future use if needed
End Type

Private Type Task_UDT
  DaysComplete         As String
  ReceivedWork         As String
  ReceivedPLPD         As String
  CompanySubContractor As String
  ReceivedSubWork      As String
  ReceivedSubPLPD      As String
  FutureUse            As String 'not used
   TempNotUsed        As String ' for future use if needed
End Type

Private Type RoofCompany_UDT
  CompanyName  As String
  Address      As String
  City         As String
  State        As String
  Zip          As String
  sqs          As String
  BidAmount    As String
  BidMaterial  As String
  Bid2Amount   As String
  Bid2Material As String
  sDate        As String
  BusYrs       As String
  Estimator    As String
  Email        As String
  Notes        As String
  TempNotUsed  As String ' for future use if needed
  Phones       As Phone_UDT
  Tasks        As Task_UDT
End Type

Private RoofCompany() As RoofCompany_UDT

Open in new window

0
Comment
Question by:isnoend2001
  • 4
  • 3
7 Comments
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40336895
There's no need to clear them. Think of them as just another type of variable like a String. In that case of course you know that you don't have to do this

Dim strTemp As String

strTemp = "Old"
strTemp = ""
strTemp = "New"

Open in new window


And so you don't have to do it with your UDTs either.
0
 

Author Closing Comment

by:isnoend2001
ID: 40336945
Thanks good to know
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40336992
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:isnoend2001
ID: 40337010
i think this may not work What if:
The first time the udt is used 10 of the fields are used
The 2nd time only 5 field are overwritten
would this not leave the old data ? in some of the fields
only the first field is required to save(CompanyName)
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40337072
Again it's just like the situation with a String. If the string is locally defined as in a Sub or Function, that string is automatically initialized each time the Sub or Function is run. So if you do this you don't have to worry about it

Private Type Info_UDT
  CompanyName  As Byte
  Address      As Byte
  sDate        As Byte
  City         As Byte
  State        As Byte
  Zip          As Byte
  Estimator    As Byte
  BidAmount    As Byte
  sqs          As Byte
  BidMaterial  As Byte
  Email        As Byte
  Bid2Material As Byte
  Bid2Amount   As Byte
  BusYrs       As Byte
  TempNotUsed   As Byte ' for future use if needed
End Type

Private Sub Test
Dim IU As Info_UDT

Msgbox IU.CompanyName '<---- will always display a blank
IU.CompanyName = "Apple"
End Sub

Open in new window


However here you would have to manually initialize the unchanged portions of the UDT

Private Type Info_UDT
  CompanyName  As Byte
  Address      As Byte
  sDate        As Byte
  City         As Byte
  State        As Byte
  Zip          As Byte
  Estimator    As Byte
  BidAmount    As Byte
  sqs          As Byte
  BidMaterial  As Byte
  Email        As Byte
  Bid2Material As Byte
  Bid2Amount   As Byte
  BusYrs       As Byte
  TempNotUsed   As Byte ' for future use if needed
End Type
Private IU As Info_UDT

Private Sub Test

Msgbox IU.CompanyName '<---- will display a blank the first time but "Apple" after that unless changed
IU.CompanyName = "Apple"
End Sub

Open in new window

0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40337086
In the second situation you could create a Sub like this one and call it when you need to. (BTW why do you use Byte?)

Private Sub Init()
 IU.CompanyName = ""
  IU.Address  = ""
  IU.sDate  = ""
  IU.City  = ""
  IU.State  = ""
  IU.Zip  = ""
  IU.Estimator = ""
  IU.BidAmount  = ""
  IU.sqs  = ""
  IU.BidMaterial  = ""
  IU.Email  = ""
  IU.Bid2Material = ""
  IU.Bid2Amount  = ""
  IU.BusYrs  = ""
  IU.TempNotUsed  = ""
End Sub

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 40337226
Thanks,
Don't know about byte, somebody else wrote the udts
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question