devxlogo

Union Structure in Visual Basic

Union Structure in Visual Basic

When using C++, the Union enables programmers to look at the same memory area from different perspectives. The same is possible in Visual BASIC. There is an LSET statement that allows two variables to be overlapped in the same memory area.

  Private Type MyType1    x as Integer    y as Integer    z as Integer    w as IntegerEnd Type Private Type MyType2    a as Long    b as LongEnd Type Private Sub Form_Load()    Dim t1 as MyType1    Dim t2 as MyType2    t1.x = 0    t1.y = 0    t1.z = -1    t1.w = -1     LSet t2 = t1    Call MsgBox (t2.a &

devx-admin

Share the Post: