hey everybody i need some help with my school project
im useing visual basic 5

the project is to make a program for a radio station with 3 forms a main a new and a uniquenumber.

the idea was that everysong saved into the program was given a unique number

the main form contained textboxes that represent
song, cd, artist and unique number with 3 buttons search, random and new

the new button shows a new form with blank fields song cd artist then 2 buttons cancel and enter enter takes the user to another form to give a unique number

plese help me im haveing a hard time with the code :(

Dani AI

Generated

Thread summary for the code bits is stuck on (saving records and switching between forms), with short, practical examples for Visual Basic 5. As asked, this separates the problem into storage (where to put records) and UI flow (how to show the "enter unique number" form). As joked, this is not a full app but a minimal, reliable pattern to build on.

A simple, robust storage approach for a school project is a local text file where each record is written with Write # (it quotes strings and makes Input/Write pairs easy to parse). Keep a tiny counter file for the next unique ID so IDs are sequential and fast to get:

' Module-level helper
Function GetNextID() As Long
    Dim fnum As Integer, id As Long
    On Error Resume Next
    fnum = FreeFile
    Open App.Path & "\nextid.txt" For Input As #fnum
    Input #fnum, id
    Close #fnum
    If id = 0 Then id = 1
    fnum = FreeFile
    Open App.Path & "\nextid.txt" For Output As #fnum
    Print #fnum, id + 1
    Close #fnum
    GetNextID = id
End Function

Sub SaveSong(sng As String, cd As String, artist As String)
    Dim id As Long, fnum As Integer
    id = GetNextID()
    fnum = FreeFile
    Open App.Path & "\songs.txt" For Append As #fnum
    Write #fnum, id, sng, cd, artist
    Close #fnum
End Sub

For form flow, show the unique-number form modally so the main/new forms pause until an ID is supplied, and pass field data via a Public variable or module-level property:

' In a standard module
Public PendingSong As String

' From New form (Enter button)
PendingSong = txtSong.Text
frmUniqueNumber.Show vbModal

' In frmUniqueNumber Form_Load
txtSong.Text = PendingSong
' When unique number entered: call SaveSong(...) then Unload Me

Notes and cautions: validate fields before saving; Write/Input handles quoting but the delimiter is comma, so keep record format consistent; file locking/concurrency can be an issue with multiple simultaneous users (fine for single-computer school projects). For a more scalable solution later, switch to an Access (.mdb) backend with ADO/DAO and parameterized SQL.

Recommended Answers

All 3 Replies

Which bit are you having a hard time with ?

Or should we deliver a complete program for you ;-)

Or should we deliver a complete program for you ;-)

no lol only if you want to
im haveing trouble with saveing data into the program and my code for showing diffrent forms isnt working

sry should have been more specific

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.