I have been using arrays for a while in my Visual basic applications (my friend showed me how to use them)
this is an example of a array I use in VB.net
Say I wanted to add a cash payment to the Tender array i would call this
Code: Select all
AddToTenderList("CASH", "", (TenderValue / 100), "", "")
Code: Select all
Public TenderPayment As New List(Of TenderItem)
Public Sub AddToTenderList(ByVal Line1 As String, ByVal Line2 As String, ByVal LineTotal As Decimal, ByVal CardSlipData_Print As String, ByVal CardSlipData_View As String)
TenderPayment.Add(New TenderItem(TenderPayment.Count, Line1, Line2, LineTotal, CardSlipData_Print, CardSlipData_View))
LoadItemsTender()
End Sub
Private Sub LoadItemsTender()
Dim spaceNeeded As Integer
FrmTenderScreen.ListTenders.Items.Clear()
For Each i As TenderItem In TenderPayment
item = vbNullString
item = i.Line1_Tender
spaceNeeded = Len(item)
If i.Line2_Tender <> "" Then
item += vbNewLine & i.Line2_Tender
spaceNeeded = Len(i.Line2_Tender)
End If
spaceNeeded += Len(Format(Val(i.Price_Tender), "£######0.00"))
item += Space((DisplayWidth - 2 - spaceNeeded)) & Format(Val(i.Price_Tender), "£######0.00")
With FrmTenderScreen.ListTenders
.DrawMode = DrawMode.OwnerDrawVariable
.Items.Add(item)
If .Items.Count > 0 Then
.SelectedIndex = .Items.Count - 1
End If
End With
Next
End Sub
This is the Class code that powers the array settings
Code: Select all
Public Class TenderItem
Public ID_Tender As Integer
Public Line1_Tender As String
Public Line2_Tender As String
Public Price_Tender As Decimal
Public CardSlipData_Print As String
Public CardSlipData_View As String
Public Sub New(ByVal ItemID As Integer, ByVal Line1_Description As String, ByVal Line2_Description As String, ByVal ItemPrice As Decimal, ByVal LocalCardSlipData_Print As String, ByVal LocalCardSlipData_View As String)
ID_Tender = ItemID
Line1_Tender = Line1_Description
Line2_Tender = Line2_Description
Price_Tender = ItemPrice
CardSlipData_Print = LocalCardSlipData_Print
CardSlipData_View = LocalCardSlipData_View
End Sub
End Class
Would someone be kind enough to show me how to use simple arrays in FreeBASIC