0% found this document useful (0 votes)
195 views32 pages

Cabpresentation

This document contains code for a visual basic project that builds a customizable automated car (CAB). It includes code to: 1. Get user profile information like name, age, gender, and preferences for different CAB applications. 2. Save the user profile and application selection data to a text file. 3. Populate a list box to display saved CAB user profiles from text files. 4. Retrieve a selected user's profile data from a text file and launch the CAB interface populated with their preferences.

Uploaded by

api-316819120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
195 views32 pages

Cabpresentation

This document contains code for a visual basic project that builds a customizable automated car (CAB). It includes code to: 1. Get user profile information like name, age, gender, and preferences for different CAB applications. 2. Save the user profile and application selection data to a text file. 3. Populate a list box to display saved CAB user profiles from text files. 4. Retrieve a selected user's profile data from a text file and launch the CAB interface populated with their preferences.

Uploaded by

api-316819120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Eric Lindberg

RA632 Visual Basic Project


St. Marys University of Minnesota

CAB Main Page

CAB Main Page: Get Instructions

CAB Build My CAB: Profile Information

CAB Build My CAB: Profile Information

ERROR CHECKING CODE HERE


ACTUAL ASSIGNMENT CODE:
'Filling the Module Variables
If ErrorFlag = False Then
ProfileName = txtName.Text
ProfileAge = txtAge.Text
ProfileZip = txtZip.Text
ProfileColor = cboColor.Text
If rdbMale.Checked = True Then
ProfileGender = "Male"
ElseIf rdbFemale.Checked = True Then
ProfileGender = "Female"
End If
Me.Hide()
appSelectForm.Show() 'Advance to SelectForm
End If

CAB Build My CAB: Application Selection

CAB Drive: Application Selection

CAB Build My CAB: Application Selection

'Ask user to save or not


SaveResult = MessageBox.Show("Do you want to save this CAB?", "Please Confirm", MessageBoxButtons.YesNo)
If SaveResult = Windows.Forms.DialogResult.Yes Then
NoSpaceName = Replace(ProfileName, " ", "")
Try
'Create a directory acting as Database
If (Not Directory.Exists("CABusers")) Then
Directory.CreateDirectory("CabUsers")
End If
NewCabFileName = "CABusers\" & NoSpaceName & ".txt" 'Remove user entered spacing from name
NewCabFile = File.CreateText(NewCabFileName) 'Accpt new name as new CABFileName
'Write lines from Results
NewCabFile.WriteLine(ProfileName)
NewCabFile.WriteLine(ProfileAge)
NewCabFile.WriteLine(ProfileZip)
NewCabFile.WriteLine(ProfileGender)
NewCabFile.WriteLine(ProfileColor)
NewCabFile.WriteLine(ClockBool)
NewCabFile.WriteLine(MediaPlayerBool)
NewCabFile.WriteLine(WeatherBool)
NewCabFile.WriteLine(NotesBool)
NewCabFile.WriteLine(ImageViewerBool)
NewCabFile.WriteLine(WebBrowserBool)
NewCabFile.Close()
MessageBox.Show("Your CAB has been successfully saved") 'Verify user save success to user
Catch
MessageBox.Show("Error: The file cannot be created.") 'Notify user of save failure
End Try
End If
Me.Hide()
driveCabForm.Show() 'Advance to CabForm

CAB Drive

CAB Drive: Female User Example

If MediaPlayerBool = True Then


CurrentLocation = Locations(LocationCount)
btnMediaPlayer.Location = New Point(CurrentLocation, 228)
btnMediaPlayer.Visible = True
LocationCount += 1
End If
If WeatherBool = True Then
CurrentLocation = Locations(LocationCount)
btnWeather.Location = New Point(CurrentLocation, 228)
btnWeather.Visible = True
LocationCount += 1
End If
If NotesBool = True Then
CurrentLocation = Locations(LocationCount)
btnNotes.Location = New Point(CurrentLocation, 228)
btnNotes.Visible = True
LocationCount += 1
End If
If ImageViewerBool = True Then
CurrentLocation = Locations(LocationCount)
btnImageViewer.Location = New Point(CurrentLocation, 228)
btnImageViewer.Visible = True
LocationCount += 1
End If
If WebBrowserBool = True Then
CurrentLocation = Locations(LocationCount)
btnWebBrowser.Location = New Point(CurrentLocation, 228)
btnWebBrowser.Visible = True
LocationCount += 1
End If
If ClockBool = True Then
lbltimedate.Visible = True
End If

CAB Drive: User Profile

CAB Drive: Media Player

CAB Drive: Weather

CAB Drive: Notes

CAB Drive: Notes

CAB Drive: Image Viewer

CAB Drive: Web Browser

CAB Main Page

Select CAB User

POPULATES LIST BOX CODE:


Public Class frmCabUsersList 'Form Load
Private Sub frmCabUsersList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
'Declare variables
Dim CabUsers As String
CabUsers = "CabUsers"
Dim Files() As System.IO.FileInfo 'create array of fileinformation types
Dim DirInfo As New System.IO.DirectoryInfo(CabUsers) 'create directory information type on
cabusers
Files = DirInfo.GetFiles("*", IO.SearchOption.AllDirectories) 'get all files in cabusers directory
For Each File In Files 'Add add each userfile to listbox
lstSavedCABUsers.Items.Add(File)
Next
End Sub

Private Sub btnSubmitCABUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmitCABUser.Click


'Declare Variables
Dim CABListString As String
Dim CABUserFile As StreamReader
Dim driveCabForm As New frmDriveCab
Try
If lstSavedCABUsers.SelectedIndex = -1 Then
MessageBox.Show("Please choose a Saved CAB Name") 'Error checking for CAB Name Choice
Else
CABListString = lstSavedCABUsers.SelectedItem.ToString
CABListString = "CabUsers\" & CABListString
'Open the file
CABUserFile = File.OpenText(CABListString)
'Read the file Data
ProfileName = CABUserFile.ReadLine
ProfileAge = CABUserFile.ReadLine
ProfileZip = CABUserFile.ReadLine
ProfileGender = CABUserFile.ReadLine
ProfileColor = CABUserFile.ReadLine
ClockBool = CABUserFile.ReadLine
MediaPlayerBool = CABUserFile.ReadLine
WeatherBool = CABUserFile.ReadLine
NotesBool = CABUserFile.ReadLine
ImageViewerBool = CABUserFile.ReadLine
WebBrowserBool = CABUserFile.ReadLine
CABUserFile.Close()
Me.Hide()
driveCabForm.Show() 'Advance to CabForm
End If
Catch
MessageBox.Show("The file cannot be opened") 'Notify User of file Error
End Try
End Sub
End Class

CAB Drive: Retrieved CAB User

You might also like