Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Help writing sub process to search through a structure. Very basic coding.

$
0
0
Hey everyone, I am looking for some help with some basic coding.
I am new at VB and I am having trouble writing a sub procedure that is capable of searching through my structure.

Any help would be appreciated, below is my code so far.

structure:
Code:

Imports System.IO

Public Class Form1
    Const strFILENAME As String = "Videos.txt"
    Structure VideoData
        Dim name As String
        Dim yearProduced As String
        Dim runningTime As String
        Dim rating As String
    End Structure

    Private Sub mnuFileSaveRecord_Click(sender As System.Object, e As System.EventArgs) Handles mnuFileSaveRecord.Click
        Dim video1 As VideoData

        With video1
            .name = CStr(txtName.Text)
            .yearProduced = CStr(txtYear.Text)
            .runningTime = CStr(txtTime.Text)
            .rating = CStr(txtRating.Text)
        End With
        WriteRecordToFile(video1)
    End Sub

And this is my output subprocedure:
Code:

    Sub WriteRecordToFile(ByRef video As VideoData)
        Dim outFile As StreamWriter

        outFile = File.AppendText(strFILENAME)

        outFile.WriteLine(video.name)
        outFile.WriteLine(video.yearProduced)
        outFile.WriteLine(video.runningTime)
        outFile.WriteLine(video.rating)
        outFile.Close()
        ClearForm()
    End Sub

So how would I go about writing a searching sub process? I would also like to be able to inform the user if the txt file hasnt been created yet.
I made an input box through a menu command, but that's as far as I can get

Code:

    Private Sub mnuSearchClick_Click(sender As System.Object, e As System.EventArgs) Handles mnuSearchClick.Click
        InputBox("Enter video name:", "Search")
    End Sub

Thanks.

-Jeff

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>