Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,085 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,799 people online right now. Registration is fast and FREE... Join Now!




MS Access Database - please help

 
Reply to this topicStart new topic

MS Access Database - please help

carlysarah
22 Apr, 2008 - 08:52 AM
Post #1

New D.I.C Head
*

Joined: 3 Apr, 2008
Posts: 49

My aim is to create a "favourites" function on my form. the user should be able to select any "station" held in the favourites database, and the "radio" should tune to and play, that station.

The information stored in the database should be the frequency, smart name and mode (AM or FM)



But, i have absolutely no idea how to create the database, and how i could then use the database to allow the user to access the information- could i do it in a list box?



Someone please give me a little guidance on the subject as i am totally clueless about using MS access databases and havent a clue how to even start. I have a database already made up: the database is called radio, the table is called stations and i have 3 columns named: frequency, smart name and mode (although, i am uncertain what to save the data type as - i think i might be able to save it as number(either 1 or 0) and use the information stored in the vb programme to automatically read it as 1 being AM and 0 being FM - though if someone could confirm this that would be great.)

Please can someone try help me out in setting this database up to use on the form as i really dont know how to do it at all.



This is the code i have for form 1:

CODE
Private Sub btnPower_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPower.Click
        If Mode = ModeEnum.OffMode Then
            Mode = ModeEnum.OnMode
            AxMediaPlayer1.FileName = "c:\cwmusic\ChrisBrown.mp3"

        Else
            Mode = ModeEnum.OffMode
            AxMediaPlayer1.Stop()
            Dim sw As New IO.StreamWriter("c:\lastStation.txt")

            sw.Write(radioStations(0).ToString)

            sw.Close()
        End If
        SetMode(Me, Mode)
    End Sub

    Dim radioStations(19) As Station


    Private Mode As ModeEnum = ModeEnum.OffMode
    Enum ModeEnum
        OnMode
        OffMode
    End Enum
    Sub SetMode(ByVal ctl As Control, ByVal mode As ModeEnum)
        Dim blnEnabled As Boolean = (mode = ModeEnum.OnMode)
        For Each subCtl As Control In ctl.Controls
            If Not subCtl.Name = "btnPower" Then
                subCtl.Enabled = blnEnabled
            End If
            If subCtl.HasChildren Then SetMode(subCtl, mode)
        Next
    End Sub



    Private Sub TckbarVolume_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TckbarVolume.Scroll
        AxMediaPlayer1.Volume = TckbarVolume.Value * 10
    End Sub



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetMode(Me, ModeEnum.OffMode)

        Dim fileName As String = "C:\lastStation.txt"
        Dim textLine As String = String.Empty
        Try
            If System.IO.File.Exists("C:\lastStation.txt") Then
                Dim reader As New System.IO.StreamReader(fileName)
                Do While reader.Peek() <> -1
                    textLine += reader.ReadLine()
                    textLine += Environment.NewLine()
                Loop
            Else
                textLine = "File not found!"
            End If
        Catch Ex As Exception
            textLine = Ex.Message
        End Try
        lblStationInfo.Text = textLine




        radioStations(0) = New Station("Classic Rock", "http://www.cfm.com", RadioBand.FM)
        radioStations(0).SongName = "c:\cwmusic\Kylie.mp3"

        radioStations(1) = New Station("Carly's Test", "http://www.cfm.com", RadioBand.AM)
        radioStations(1).SongName = "c:\cwmusic\Snowpatrol.mp3"

        radioStations(2) = New Station("Carly's Test Station2", "http://www.cfm.com", RadioBand.FM)
        radioStations(2).SongName = "c:\cwmusic\Kylie.mp3"






    End Sub





    Private Sub btnScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan.Click
        AxMediaPlayer1.Mute = True
        Dim oForm As New Form2
        oForm.ShowDialog()
        AxMediaPlayer1.Mute = False
    End Sub


    Private Sub btnMute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMute.Click
        If AxMediaPlayer1.Mute Then
            AxMediaPlayer1.Mute = False
        Else
            AxMediaPlayer1.Mute = True
        End If
    End Sub

    Private Sub radiobtnAM_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radiobtnAM.CheckedChanged
        If radiobtnAM.Checked Then
            Module1.AM = True
        Else
            Module1.AM = False
        End If
    End Sub



    Private Sub radiobtnFM_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radiobtnFM.CheckedChanged
        If radiobtnFM.Checked Then
            Module1.AM = False
        Else
            Module1.AM = True
        End If
    End Sub


    Private Sub Station1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Station1.Click
        AxMediaPlayer1.FileName = "c:\cwmusic\Ronan.mp3"
        lblStationInfo.Text = radioStations(0).ToString()
    End Sub

    Private Sub Station2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Station2.Click
        AxMediaPlayer1.FileName = "c:\cwmusic\Snowpatrol.mp3"
        lblStationInfo.Text = radioStations(1).ToString()

    End Sub

    Private Sub station3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles station3.Click
        AxMediaPlayer1.FileName = "c:\cwmusic\Kylie.mp3"
        lblStationInfo.Text = radioStations(2).ToString()
    End Sub

    Public Class Station
        Private InfoText As String
        Private URL As String
        Private Band As RadioBand


        Private song As String

        Public Sub New()
        End Sub

        Public Sub New(ByVal InfoText As String, _
         ByVal URL As String, _
        ByVal Band As RadioBand)
            Me.InfoText = InfoText
            Me.URL = URL
            Me.Band = Band
        End Sub

        Public Property SongName()
            Get
                Return song
            End Get
            Set(ByVal value)
                song = value
            End Set
        End Property

        Public Overrides Function ToString() As String
            Return Me.InfoText
        End Function
    End Class


    Public Enum RadioBand
        FM = 0
        AM = 1
    End Enum

End Class



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 11:42PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month