• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

VB.NET Help. Again. Short this time.

Status
Not open for further replies.

Soul4ger

Member
Okay, I have another VB.NET project due (for anyone who remembers the last time), and I need some quick help. I'm reading input from a data file, but I need to be able to skip one line of data. Like, the file looks like this:

"Beach, Sandy", 123, 142, 111
"Clone, Sy", 134, 127, 144
"Knee, Bo", 99, 103, 111
"Leer, Chandra", 132, 144, 167

Abbreviated versoin. Anyway, one of the buttons, "Skip," not only shifts the focus from one button to another, but it's supposed to let me skip past one line of data. For instance, say I look at Beach, Sandy, but then want to skip Clone, Sy and get right to Knee, Bo. Anyone know how to code that?
 

bjork

Member
a little bird told me:

" if it's a sequential access file, just skip it over with your for loop or whatever you've got getting your info from the file."
 

iyox

Member
OK i need to know some things first. Do you want each part of the data to be separated? Like the name and the stuff that follows? Do you have any knowledge of working with arrays?
 

Soul4ger

Member
I don't know what an array is, I don't think...

And Luke, I don't have a loop reading my data. It just does it in order.
 

BTMash

Member
Would make it easy for us to see and help out with whatever code you currently have to add in the functionality. Arrays would probably make it easier but since you haven't learnt that stuff yet, it might not be allowed in your assignment anyways.
 

Soul4ger

Member
Option Explicit On
'-------------------------------------------------------------------------------

Public Class frmBowling
Inherits System.Windows.Forms.Form
'-------------------------------------------------------------------------------

Dim mstrName As String 'bowlers name
Dim mintScoreOne As Integer 'first game score
Dim mintScoreTwo As Integer 'second game score
Dim mintScoreThree As Integer 'third game score
Dim mintAverage As Integer 'three-game average
Dim mintHighAve As Integer 'high three-game average
Dim mintLowAve As Integer 'low three-game average
Dim mstrHighName As String 'high bowlers name
Dim mstrLowName As String 'low bowlers name
'-------------------------------------------------------------------------------

Private Sub btnOpenInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenInput.Click

'open input file
FileOpen(1, "D02_In.txt", OpenMode.Input)

'initialize high & low averages
mintHighAve = 0
mintLowAve = 301
End Sub
'-------------------------------------------------------------------------------

Private Sub btnOpenOutput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenOutput.Click

'open output file
FileOpen(2, "D02_Out.txt", OpenMode.Output)
End Sub
'-------------------------------------------------------------------------------

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
End
End Sub
'-------------------------------------------------------------------------------

Private Sub btnCloseFiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseFiles.Click
FileClose(1)
FileClose(2)
End Sub
'-------------------------------------------------------------------------------

Private Sub btnSkip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSkip.Click
btnReadRecord.Focus()
End Sub
'-------------------------------------------------------------------------------

Private Sub btnReadRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadRecord.Click

'read record from file
Input(1, mstrName)
Input(1, mintScoreOne)
Input(1, mintScoreTwo)
Input(1, mintScoreThree)

'echo data
lblName.Text = mstrName
lblScoreOne.Text = CStr(mintScoreOne)
lblScoreTwo.Text = CStr(mintScoreTwo)
lblScoreThree.Text = CStr(mintScoreThree)

'calculate average
mintAverage = (mintScoreOne + mintScoreTwo + mintScoreThree) / 3

End Sub
'-------------------------------------------------------------------------------

Private Sub btnHighAverage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHighAverage.Click

'use Max/Min concept to find High average
If (mintAverage > mintHighAve) Then
mintHighAve = mintAverage
End If

'display High average
lblHighAverage.Text = CStr(mintHighAve)

End Sub
'-------------------------------------------------------------------------------

Private Sub btnLowAverage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLowAverage.Click

'use Max/Min concept to find Low average
If (mintAverage < mintLowAve) Then
mintLowAve = mintAverage
End If

'display Low average
lblLowAverage.Text = CStr(mintLowAve)

End Sub
'-------------------------------------------------------------------------------

Private Sub btnInclude_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInclude.Click

'display results in listbox
lstResults.Items.Add(mstrName & " " & mintAverage)

'write record to output file
WriteLine(2, mstrName, mintAverage)

End Sub
End Class
 

Ecrofirt

Member
See if it works when you make it look like this:

Private Sub btnSkip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSkip.Click
dim blank as string

Input(1, blank)
Input(1, blank)
Input(1, blank)
Input(1, blank)

btnReadRecord.Focus()
End Sub

this should input the next set of records worth of data, but do nothing with them. It'll push the data along to your next record, which is what you want.

At least, if I've got a grasp of your problem, anyhow.
 
Status
Not open for further replies.
Top Bottom