Results 1 to 3 of 3

Thread: assigning structure

  1. #1

    Thread Starter
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112

    assigning structure

    halu,

    i don't know if my subject gets the very title of what i wanted. hehe... i wanted to know about something like assigning structure... i encounter this in C... but this gives me error when i try to apply it in VB... code is like this...
    Code:
    typedef struct{
    	char code[10],lastname[10],firstname[10],mi,address[10];
    	int location;
    	short status;
    }salesman;
    
    main(){
    	salesman s={"01","lastname","firstname",'m',"address",1,1};
    	printf("%d\n",s.name);
    }
    is that possible in VB? just want to clarify if vb.net offers this kind of assignment...

    something like a structure receiving {data....}

    thanx guys...


    Keep fit with wossy
    "Finaly I can look as gay as I want..." - NoteMe

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No not unless you specifically build a constructor with such parameters.
    VB Code:
    1. Public Structure MyTest
    2.         Dim ID As Integer
    3.         Dim Name As String
    4.  
    5.         Sub New(ByVal id As Integer, ByVal name As String)
    6.             Me.ID = id
    7.             Me.Name = name
    8.         End Sub
    9.  
    10.     End Structure
    11.  
    12.         Dim ts As New MyTest(1, "Ed")
    13.  
    14.         MsgBox(ts.ID & " " & ts.Name)
    You can only use that syntax {} with assigning items to an array in .net.
    VB Code:
    1. Dim sa As String() = {"Ed", "Mike", "Cookie"}

  3. #3

    Thread Starter
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112
    thanx very much Ed... again, again, and again....

    don't know when i'll still be doing that... perhaps if i can code...

    again... thanx... can't stop doing that... hehehe...


    Keep fit with wossy
    "Finaly I can look as gay as I want..." - NoteMe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width