Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pete's Dumb Idea of the Day!
#8
I'm uncomfortable with it. Data is good for a hard-coded part of the program where nothing will change. But - during development, who never changed anything? I like the solution with an array and a function that returns it all as a result much better, even if it takes more time to write the function. Something like this:

Code: (Select All)

Type Record
    As Integer number
    As String text1, text2
End Type
ReDim Shared Rec(0) As Record
Dim Values(1 To 4) As Integer

Values(1) = InitRecord(1, "one", "the first")
Values(2) = InitRecord(2, "two", "the second")
Values(3) = InitRecord(3, "three", "the third")
Values(4) = InitRecord(4, "four", "the forth")

For Show = 1 To 4
    PrintRecord Show
Next
Erase Rec
Erase Values
End

Function InitRecord (number As Integer, t1 As String, t2 As String)
    U = UBound(Rec) + 1
    ReDim _Preserve Rec(U) As Record
    Rec(U).number = number
    Rec(U).text1 = t1
    Rec(U).text2 = t2
    InitRecord = U
End Function

Sub PrintRecord (Id As Integer)
    Print Rec(Id).number, Rec(Id).text1, Rec(Id).text2
End Sub


Reply


Messages In This Thread
Pete's Dumb Idea of the Day! - by Pete - 10-21-2024, 07:53 PM
RE: Pete's Dumb Idea of the Day! - by TDarcos - 10-23-2024, 02:47 AM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-22-2024, 12:01 AM
RE: Pete's Dumb Idea of the Day! - by dano - 10-22-2024, 01:08 AM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-22-2024, 05:55 AM
RE: Pete's Dumb Idea of the Day! - by bplus - 10-22-2024, 10:40 AM
RE: Pete's Dumb Idea of the Day! - by a740g - 10-22-2024, 11:46 AM
RE: Pete's Dumb Idea of the Day! - by Petr - 10-22-2024, 03:57 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 01:01 AM
RE: Pete's Dumb Idea of the Day! - by SMcNeill - 10-23-2024, 03:54 AM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 07:59 AM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-23-2024, 01:07 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 05:37 PM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-23-2024, 08:09 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 10:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Select Case idea... Unseen Machine 9 1,002 08-30-2025, 12:00 AM
Last Post: Unseen Machine
  Got an idea will it work ? doppler 7 1,234 05-27-2025, 11:20 PM
Last Post: Pete
  Should I torment Pete this weekend? Cobalt 4 1,010 11-08-2024, 07:13 PM
Last Post: Pete
  Idea for two new commands TerryRitchie 9 1,780 04-06-2024, 04:02 AM
Last Post: Pete
  @Pete -- You Dummy!! SMcNeill 4 1,047 03-02-2024, 03:31 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)