Solved

How to clear the values in udt's

Posted on 2014-09-22
7
127 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 45

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 45

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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 45

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 45

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now