View Single Post
 
Old 11-28-2012, 03:36 PM
Raleigh Raleigh is offline
Newcomer
 
Join Date: Nov 2012
Posts: 1
Default Writing query to search through a structure

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
this is my output so far...
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

All I have so far is an input box
Code:
 Private Sub mnuSearchClick_Click(sender As System.Object, e As System.EventArgs) Handles mnuSearchClick.Click
        InputBox("Enter video name:", "Search")
    End Sub
Reply With Quote