Thursday, March 22, 2012

Structure Data Type

If I want to pass a structure data type to a function then what data type is it? Object? Or is it just a bad thing to pass structs?

Thanks,
TreyA struct type is a "value type" so it is not an object ( reference type ).

Sam
so say i have a sub like:


sub insertX( byVal someValue as ___________)

end sub

What goes in the ___________ part.

Thanks,
Trey
You would pass it the name of the struct you created. Say you create a struct called Employee, here is how you would pass it:

sub insertX( byVal someValue as Employee a)

//Do stuff with a

end sub

Sam
The ____ will be the structure type:

<%@. Page Language="VB" %>
<html>
<head>
<script runat="server">
Structure Favourite
Public Colour As String
Public Number As Integer
End Structure

Sub Page_Load(sender As Object, e As EventArgs)
Dim MyFavourite As New Favourite
MyFavourite.Colour = "black"
Myfavourite.Number = "10"
Report( MyFavourite )
End Sub

Sub Report( ThisFavourite As Favourite )
Message.Text = "Your favourite colour is " & ThisFavourite.Colour
Message.Text &= ", and your favourite number is " & ThisFavourite.Number.ToString()
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:Label id="Message" runat="server" />
</form>
</body>
</html>


thanks....that helped me figure out what i was doing wrong.

Trey

0 comments:

Post a Comment