Trouble clearing the data in a UDT

form level for 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
Private Info As Info_UDT

I copied and pasted the udt's and am trying to clear the udt's
The Info and Recap clear ok, but when i try to clear the Phone_UDT i get errors no matter what i try
How to clear the data in the Phone_UDT ?

Sub ClearUdts()
With Info
  .CompanyName = 0
  .Address = 0
  .sDate = 0
  .City = 0
  .State = 0
  .Zip = 0
  .Estimator = 0
  .BidAmount = 0
  .sqs = 0
  .BidMaterial = 0
  .Email = 0
  .Bid2Material = 0
  .Bid2Amount = 0
  .BusYrs = 0
  .TempNotUsed = 0 ' for future use if needed
End With

With Recap
  .CompanyName = 0
  .Estimator = 0
  .sDate = 0
  .BidAmount = 0
  .BidMaterial = 0
  .Bid2Amount = 0
  .Bid2Material = 0
  .sqs = 0
  .BusYrs = 0
   .TempNotUsed = 0    ' for future use if needed
End With

Open in new window

isnoend2001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Set the values = "" rather than 0.

If that doesn't work please show what you tried.
0
Martin LissOlder than dirtCommented:
In other words

Private Phone As Phone_UDT

With Phone
  .Cell   =  ""
  .Office   =  ""
  .Emergency   =  ""
  .Fax   =  ""
  .Owner   =  ""
  .LasrRow   =  ""
  .TempNotUsed   =  ""
End With

Open in new window

0
isnoend2001Author Commented:
Thanks that gives an error
With Phone 'variable undefined
  .Cell   =  ""
  .Office   =  ""
  .Emergency   =  ""
  .Fax   =  ""
  .Owner   =  ""
  .LasrRow   =  ""
  .TempNotUsed   =  ""
I have tried these to no avail, probably erased other attempts
With RoofCompany(CurrentCompany)
'PhoneContact = "" 
'Phones.Cell = ""
'PhoneInfo(.Phones.Cell) = ""
''PhoneInfo(.Phones.Office) = ""
'PhoneContact(0) = ""
'' PhoneContact = PhoneInfo(.Phones.Cell)
' PhoneContact(1) = ""
End With
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
Did you see line 1 in my code? That line needs to be in the same module/form as the rest of the code. If it is someplace else make it Public rather than Private.
0
Martin LissOlder than dirtCommented:
Here's code for a complete example. Add a command button to a form.

Option Explicit
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 Phone As Phone_UDT


Sub Initialize()
With Phone
  .Cell = ""
  .Office = ""
  .Emergency = ""
  .Fax = ""
  .Owner = ""
  .LasrRow = ""
  .TempNotUsed = ""
End With
End Sub

Private Sub Command1_Click()
Phone.Owner = "Marty"
MsgBox Phone.Owner
Initialize
MsgBox Phone.Owner
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
Thanks
btw changing the 0 to "" gives a type mismatch
0
Martin LissOlder than dirtCommented:
btw changing the 0 to "" gives a type mismatch
I assume you mean when the variable is defined as Byte. A String variable (as in my post ID: 40339752) will be OK.
0
isnoend2001Author Commented:
Thanks martinLiss
Re: btw changing the 0 to "" gives a type mismatch
Not sure if that would effect coding in other places
Posted a question to another site VBWire and the coder who answered decided to write the program.
Not sure how it happened
http://www.vbforums.com/showthread.php?775021-RESOLVED-How-to-Save-classes-to-binary-file-vb6

This program started as a app for Home Owners to track and compare different roofing bids
In talking to my sister who was getting Landscaping bids, she said "Too bad it would not track other Home
Owner bid types, so i decided to modify it so it would by using a combobox. My plan was this:
Make folders for each item in the combobox under the Home Owners Name-Address folder.
and add array to hold the full paths to the cbo items. This is why i need to reset all the UDT values.
Most of the code is over my head.
 Is there a reason for changing the the byte to string ?
0
Martin LissOlder than dirtCommented:
Byte variables may have their place since they are smaller and faster than strings but unless your app is slow/and or bloated and you are needing to optimize it, IMO they aren't needed. In fact if you are trying to store text values then you can't use them because it won't compile. For example I changed the code above a bit and added two versions of "Owner", one Byte and one String and line 30 is a problem. Just in case you don't know, your UDTs don't have to be all Byte or all String. Each variable in the UDT can be whatever variable type is most appropriate.

Option Explicit
Private Type Phone_UDT
  Cell      As String
  Office    As String
  Emergency As String
  Fax       As String
  Owner_String     As String
  Owner_Byte As Byte
  LasrRow   As String
  TempNotUsed   As String ' for future use if needed
End Type
Private Phone As Phone_UDT


Sub Initialize()
With Phone
  .Cell = ""
  .Office = ""
  .Emergency = ""
  .Fax = ""
  .Owner_String = ""
  .Owner_Byte = 0
  .LasrRow = ""
  .TempNotUsed = ""
End With
End Sub

Private Sub Command1_Click()
Phone.Owner_String = "Marty"
Phone.Owner_Byte = "Marty" ' <-- Type Mismatch error
MsgBox Phone.Owner_Byte
Initialize
MsgBox Phone.Owner_Byte
End Sub

Open in new window

0
isnoend2001Author Commented:
Thanks, good to know
i am sure i will have more questions by the this project is done
Thanks for the help on adding and making new cbo items selected and now
this clearing udt's.
Glad you are here
0
Martin LissOlder than dirtCommented:
So am I:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.