Home > Software engineering >  VB structure initialized to zero
VB structure initialized to zero

Time:09-22

How to structure such as topic, VB initialized to zero, there is such a function?

CodePudding user response:

In VB6, members of the "default" is "0",

CodePudding user response:

Structure to create a VB will automatically "reset", convenient!

CodePudding user response:

VB6 does not provide function, can use the API:
RtlZeroMemory clear the designated "memory" 0,
RtlFillMemory with a specified byte value "" fill the specified memory area,

CodePudding user response:

If the original poster is to want to will have used structure called a user-defined types (VB) variables to empty, just let it is equal to a new statement of the similar structure variables,
 
'A user - defined type:
Private Type udtSomeType
SubVariableOne As Integer
SubVariableTwo As String
SubVariableThree As Long
End Type

To send 'A class - level user - defined type variables:
Private TypeVariableOne As udtSomeType
Private TypeVariableTwo As udtSomeType

'A method in the class:
Private Sub ResetData ()
Dim CleanTypeVariable As udtSomeType
TypeVariableOne=CleanTypeVariable
TypeVariableTwo=CleanTypeVariable
End Sub

CodePudding user response:

reference Chen8013 reply: 3/f
VB6 does not provide function, can use the API:
RtlZeroMemory clear the designated "memory" 0,
RtlFillMemory with a specified byte value "" fill the specified memory area,

Can't do this, the member is a string, dynamic array, the object will have a problem,
Less of123 so simple, safe,

CodePudding user response:

4th floor down really is! Orz

CodePudding user response:

reference 5 floor Tiger_Zhao reply:
Quote: refer to the third floor Chen8013 response:
VB6 does not provide function, can use the API:
RtlZeroMemory clear the designated "memory" 0,
RtlFillMemory with a specified byte value "" fill the specified memory area,

Can't do this, the member is a string, dynamic array, the object will have a problem,
Less of123 so simple, safe,

Yes, members include "string, dynamic array, object, use the method of 4th floor is very good, the data space can" immediate release ",

Clear zero, but using the API process when the end of the "normal" those "data space" will still be normal release,
With API qing 0, of course, the best or only for "members are all numeric types",

CodePudding user response:

reference 4 floor of123 response:
if the original poster is want to have used structure called a user-defined types (VB) variables to empty, just let it equal to that of the similar structure variables, a new statement
 
'A user - defined type:
Private Type udtSomeType
SubVariableOne As Integer
SubVariableTwo As String
SubVariableThree As Long
End Type

To send 'A class - level user - defined type variables:
Private TypeVariableOne As udtSomeType
Private TypeVariableTwo As udtSomeType

'A method in the class:
Private Sub ResetData ()
Dim CleanTypeVariable As udtSomeType
TypeVariableOne=CleanTypeVariable
TypeVariableTwo=CleanTypeVariable
End Sub

Above which the structure of the variable is used, which is a newly defined?
  • Related