Käynnissä

VB programming tutor 1 hour

I have a fairly simple program in VB. I would like someone to spend an hour explaining how it works. I used to write some VBA macros but I am not familiar with some of the stuff in this program.

The input for the program is a csv file and the output will also be a csv file. I will paste it in below.

Thanks!

Public Class Form1

Dim finput As String = "input.csv"

Dim groupdata As String = "groupdata.csv"

Dim output As String = "output.csv"

Dim data(205, 27) As Double

Dim va(205), vb(205), v As Double

Dim gr(205), g As Byte

Private Sub button1_Click(ByVal sender As [url removed, login to view], ByVal e As [url removed, login to view]) Handles [url removed, login to view]

inp()

run()

out()

End Sub

Public Sub run()

Dim a, b As Integer

Dim tmp As Double

For a = 1 To 205

va(a) = calaver(a, gr(a))

For b = 1 To g

If b <> gr(a) Then

tmp = calaver(a, b)

If tmp < vb(a) Or vb(a) = 0 Then

vb(a) = tmp

End If

End If

Next

v = v + (vb(a) - va(a)) / max(vb(a), va(a))

Next

v = v / 205

End Sub

Function max(ByVal v1 As Double, ByVal v2 As Double) As Double

If v1 >= v2 Then

max = v1

Else

max = v2

End If

End Function

Function calaver(ByVal fr As Integer, ByVal ds As Integer) As Double

Dim a, b, n As Integer

Dim tmpv, result As Double

result = 0

n = 0

For a = 1 To 205

If gr(a) = ds And a <> fr Then

tmpv = 0

For b = 1 To 27

tmpv = tmpv + (data(fr, b) - data(a, b)) ^ 2

Next

tmpv = tmpv ^ 0.5

n = n + 1

result = result + tmpv

End If

Next

result = result / n

calaver = result

If n = 0 Then calaver = 0

End Function

Public Sub inp()

Dim fn, a, b As Integer

fn = FreeFile()

FileOpen(fn, finput, [url removed, login to view])

For a = 1 To 205

For b = 1 To 27

Input(fn, data(a, b))

Next

Next

FileClose(fn)

FileOpen(fn, groupdata, [url removed, login to view])

For a = 1 To 205

Input(fn, gr(a))

If gr(a) > g Then

g = gr(a)

End If

Next

FileClose(fn)

End Sub

Public Sub out()

Dim fn, a As Integer

fn = FreeFile()

FileOpen(fn, output, [url removed, login to view])

For a = 1 To 205

WriteLine(fn, va(a), vb(a), (vb(a) - va(a)) / max(vb(a), va(a)))

Next

Write(fn, v)

FileClose(fn)

End Sub

Private Sub Button2_Click(ByVal sender As [url removed, login to view], ByVal e As [url removed, login to view]) Handles [url removed, login to view]

End

End Sub

End Class

Taidot: Koulutus, Visual Basic

Näytä lisää: would 1, visual basic in programming, vb this, vba tutor, string programming, string c programming, string b, public programming, programming with data, programming object, programming n, programming macros, programming in visual basic, programming in vba, programming in basic, programming if, programming function, programming class, object in programming, max programming, in system programming, in programming, in hour, if then programming, if programming

Tietoa työnantajasta:
( 53 arvostelua ) Beppu shi, Japan

Projektin tunnus: #189600