|
-
Mar 17th, 2015, 09:55 AM
#1
Thread Starter
Fanatic Member
working with types , Copy data of type inside other variable with different type
Hi
I would like working variables like below
Code:
Private Type AA
AA01 As String * 2
AA02 As String * 2
End Type
Private Type BB
BB01 As String * 4
End Type
Private Sub Form_Load()
Dim K As AA
Dim L As BB
K.AA01 = "11"
K.AA02 = "22"
'Here I want put the data of K inside L
'Is there some way to do it ?
End Sub
-
Mar 17th, 2015, 09:59 AM
#2
Re: working with types , Copy data of type inside other variable with different type
Code:
L.BB01 = K.AA01 & K.AA02
Debug.Print L.BB01
-
Mar 17th, 2015, 10:09 AM
#3
Thread Starter
Fanatic Member
Re: working with types , Copy data of type inside other variable with different type
Thank you, But Is there some way to do put the put the data directly, no field by field
Like
L = K?
-
Mar 17th, 2015, 11:17 AM
#4
Re: working with types , Copy data of type inside other variable with different type
Look up the LSet statement.
-
Mar 17th, 2015, 04:43 PM
#5
Re: working with types , Copy data of type inside other variable with different type
Yes ofcourse, forgot all about the LSet statement!
-
Mar 17th, 2015, 05:52 PM
#6
Re: working with types , Copy data of type inside other variable with different type
My preference would be to write a function before using LSet.
Code:
Option Explicit
Private Type AA
AA01 As String * 2
AA02 As String * 2
End Type
Private Type BB
BB01 As String * 4
End Type
Private Sub Form_Load()
Dim K As AA
Dim L As BB
K.AA01 = "11"
K.AA02 = "22"
L = ToBB(K)
MsgBox L.BB01
End Sub
Private Function ToBB(A As AA) As BB
ToBB.BB01 = A.AA01 & A.AA02
End Function
Burn the land and boil the sea
You can't take the sky from me
~T
-
Mar 17th, 2015, 08:52 PM
#7
Re: working with types , Copy data of type inside other variable with different type
If somebody is playing with UDTs for anything but API call "struct" stand-ins they are probably lost anyway.
-
Mar 18th, 2015, 03:23 AM
#8
Re: working with types , Copy data of type inside other variable with different type
Do you prefer classes above UDTs in all situations?
-
Mar 18th, 2015, 03:06 PM
#9
Re: working with types , Copy data of type inside other variable with different type
For me there is no one size fits all answer.
Burn the land and boil the sea
You can't take the sky from me
~T
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|