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

VS 2010 Saving/Opening array issues

$
0
0
Here is my goal in order of how I want the program to operate:

1. The user chooses one of 4 tabs

2. Within of these 4 tabs the user will enter data in 22 locations. Along with a monthly calendar who will have the current day selected as a default but the user is allowed to select a prior date.

3. The user will click a submit button, entering the data into variables (strings/integers/the date). This then brings up a save dialog box, where the user can enter a new location or pick a past text file with entered data. I will eventually want to check if there is data written to a date that the user has selected and bring up a message box requiring confirmation from the user before writing over the data.

Aside the message box requiring confirmation I got the above tasks to work, but not ideally. I set a string variable array as seen in my code and wrote in a comma in between submissions. This worked but I would get a comma at the end of my saved info in my text file (I don't think this will hinder my later goals) also when submitting my entered data would not automatically start on a new line unless I stopped debug and restarted the debug and saved again. What I mean by this is that if I was to submit multiple times without closing out and reopening the program it would just write the code as one long line.

4. There is also a tab that allows a user to review data entered on a certain date. Within this tab I have 22 open areas for the recorded data, another monthly calendar, and a review/open records button.

5. The user will receive a message box stating there is no entered data if a date with no recorded data is chose and the review button is chosen.

6. I would also like the ability to amend data within this tab and was thinking about a third button, that once data is brought up will bring up a message box requiring confirmation from the user before writing over the data.

This is where I'm mostly at a loss, I have picked out certain points of my code and added them below. I was wondering, if as opposed to having one variable array I would need 22 variable arrays, since I would prefer the user open the records once and be able to navigate the calendar and hit review to pull up past days without issue.

Code:

Imports System.IO

Public Class Form1

    Dim intMainWeight As Integer
    Dim intSecondWeight As Integer
    Dim intThirdWeight As Integer
    Dim intFourthWeight As Integer
    Dim intFifthWeight As Integer

    Dim intMainLiftReps As Integer
    Dim intSecondLiftReps As Integer
    Dim intThirdLiftReps As Integer
    Dim intFourthLiftReps As Integer
    Dim intFifthLiftReps As Integer

    Dim intMainLiftSets As Integer
    Dim intSecondLiftSets As Integer
    Dim intThirdLiftSets As Integer
    Dim intFourthLiftSets As Integer
    Dim intFifthLiftSets As Integer

    Dim strSecondExerc As String
    Dim strThirdExerc As String
    Dim strFourthExerc As String
    Dim strFifthExerc As String

    Dim strMiscLiftNotes As String
    Dim strLiftDate As String

    Dim strLiftInformation(21) As String
    Dim strCompiledLiftData As String
    Dim strSaveFile As String

        strLiftInformation(0) = strLiftDate

        strLiftInformation(1) = "Squats"
        strLiftInformation(2) = intMainWeight.ToString
        strLiftInformation(3) = intMainLiftReps.ToString
        strLiftInformation(4) = intMainLiftSets.ToString

        strLiftInformation(5) = strSecondExerc
        strLiftInformation(6) = intSecondWeight.ToString
        strLiftInformation(7) = intSecondLiftReps.ToString
        strLiftInformation(8) = intSecondLiftSets.ToString

        strLiftInformation(9) = strThirdExerc
        strLiftInformation(10) = intThirdWeight.ToString
        strLiftInformation(11) = intThirdLiftReps.ToString
        strLiftInformation(12) = intThirdLiftSets.ToString

        strLiftInformation(13) = strFourthExerc
        strLiftInformation(14) = intFourthWeight.ToString
        strLiftInformation(15) = intFourthLiftReps.ToString
        strLiftInformation(16) = intFourthLiftSets.ToString

        strLiftInformation(17) = strFifthExerc
        strLiftInformation(18) = intFifthWeight.ToString
        strLiftInformation(19) = intFifthLiftReps.ToString
        strLiftInformation(20) = intFifthLiftSets.ToString

    Private Sub btnLegs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLegs.Click

        strMiscLiftNotes = rtfMiscLegs.Text


        strLiftDate = calLegs.SelectionStart.ToString("MM/dd/yyyy")

        strLiftInformation(21) = strMiscLiftNotes

        For intIndex = 0 To 21
            strCompiledLiftData &= strLiftInformation(intIndex) & ","
        Next

        SaveFileDialog1.ShowDialog()

    End Sub


    Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk

        Dim objWriter As New IO.StreamWriter(SaveFileDialog1.FileName, True)
        objWriter.Write(strCompiledLiftData)
        objWriter.Close()

    End Sub


    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        Dim objFileReader As New IO.StreamReader(OpenFileDialog1.FileName)

        Do Until objFileReader.Peek = -1 <---------------?????? This section?

        Loop

        objFileReader.Close()

    End Sub


    Private Sub btnOpenRecrds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenRecrds.Click
        OpenFileDialog1.ShowDialog()
    End Sub


Viewing all articles
Browse latest Browse all 42215

Trending Articles



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