KMS wrote:
> Добрый день, форумяне.
>
> Вот дернул же меня черт схватиться за VB.NET.
> Второй день не могу сделать казалось бы простую вещь.
> Видимо сказывается большой перерыв в программировании.
>
> Прошу вот чего.
> Задача такая.
> Есть текстовый файл с данными.
> Я его загоняю в
> Public Structure OC
> Dim Symbol As String
> Dim Shares As Integer
> Dim Pivot As Single
> Dim Close As Single
> End Structure
>
> Подскажите, пожалуйста, каким образом мне эту структуру вывести в
> таблицу в форму. Т.е. что делать дальше.
> С массивами, вроде, понятно, а вот со структурой — никак.
>
> Спасибо большое.
>
> С уважением, Коняев Павел.
Пример:
' an example of structure that contains a fixed length string
Structure PersonStruct
Dim FirstName As String
Dim LastName As String
Public Address As String
Private SSN As String
' Simulate a fixed-length string.
Dim ZipCode As Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString
' A constructor for this structure.
Sub New(ByVal firstName As String, ByVal lastName As String)
Me.FirstName = firstName
Me.LastName = lastName
' Initialize the fixed-length string.
ZipCode = New Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString(10)
End Sub
Function CompleteName() As String
CompleteName = FirstName & " " & LastName
End Function
End Structure
' this procedure demonstarte usage of Structures
Sub TestStructures()
' Creation is similar, but structures don't require New.
Dim sPers As PersonStruct ' New is optional.
' Assignment to members.
sPers.FirstName = "Joe"
sPers.LastName = "Doe"
' Method and property invocation.
Console.WriteLine(sPers.CompleteName()) ' => Joe Doe
' Assignment to a variable.
Dim sPers2 As PersonStruct = sPers
' Structure are value types, hence the new variable receives
' a copy of the original structure.
sPers2.FirstName = "Ann"
' The original structure hasn't been affected
Console.WriteLine(sPers.FirstName) ' => Joe
End Sub
Peter
Posted via RSDN NNTP Server 1.8