del variable
Hvis man har to classer og man har læst data ind i nogle variablei den ene, også springer til den anden og vil bruge de samme verdier her hvordan gør man det uden at verdierne forsvinder?
jeg skriver i vb Express
Imports System.IO
Public Class ReadFile
Public customer As String
Public offerid As String
Public type As String
Public varenr As String
Public length As String
Public width As String
Public motorItem As String
Public diameter As String
Public idlerItem As String
Public sideheight As String
Public sideRightItem As String
Public sideLeftItem As String
Public bottomItem As String
Public beltItem As String
Public rollerItem As String
Public steelItem As String
Public conveyorItem As String
Public conveyorParameters As String
Public bottomParameters As String
Public conveyorMaterial As String
Public motorMaterial As String
Public sideRightParameters As String
Public sideLeftParameters As String
Public idlerParameters As String
Public beltParameters As String
Public rollerParameters As String
Public rollerMaterial As String
Public steelParameters As String
Public motorParameters As String
Public beslag2Item As String
Public beslag2Parameters As String
Public pos As String
Public dato As String
Public state As String
Public newvarenr As New FindVarenr
Public Sub ReadCSVFileToArray(ByVal id As Integer)
Dim strfilename As String
Dim num_rows As Long
Dim num_cols As Long
Dim x As Integer
Dim y As Integer
Dim strarray(1, 1) As String
' Load the file.
Form1.state = "File is loading"
strfilename = "C:\Documents and Settings\Kim Almind Pedersen\Skrivebord\Test.txt"
'Check if file exist
If File.Exists(strfilename) Then
Dim tmpstream As StreamReader = File.OpenText(strfilename)
Dim strlines() As String
Dim strline() As String
strlines = tmpstream.ReadToEnd().Split(Environment.NewLine)
' Redimension the array.
num_rows = UBound(strlines)
strline = strlines(0).Split(",")
num_cols = UBound(strline)
ReDim strarray(num_rows, num_cols)
' Copy the data into the array.
strline = strlines(x).Split(",")
For y = 0 To num_cols
strarray(x, y) = strline(y)
Next
If UBound(strline) = 31 Then
customer = strarray(0, 0)
offerid = strarray(0, 1)
type = strarray(0, 2)
length = strarray(0, 3)
width = strarray(0, 4)
motorItem = strarray(0, 5)
diameter = strarray(0, 6)
idlerItem = strarray(0, 7)
sideheight = strarray(0, 8)
sideRightItem = strarray(0, 9)
sideLeftItem = strarray(0, 10)
bottomItem = strarray(0, 11)
beltItem = strarray(0, 12)
rollerItem = strarray(0, 13)
steelItem = strarray(0, 14)
conveyorItem = strarray(0, 15)
conveyorParameters = strarray(0, 16)
bottomParameters = strarray(0, 17)
conveyorMaterial = strarray(0, 18)
motorMaterial = strarray(0, 19)
sideRightParameters = strarray(0, 20)
sideLeftParameters = strarray(0, 21)
idlerParameters = strarray(0, 22)
beltParameters = strarray(0, 23)
rollerParameters = strarray(0, 24)
rollerMaterial = strarray(0, 25)
steelParameters = strarray(0, 26)
motorParameters = strarray(0, 27)
beslag2Item = strarray(0, 28)
beslag2Parameters = strarray(0, 29)
pos = strarray(0, 30)
dato = strarray(0, 31)
Else
Form1.state = "File Error"
'MsgBox("Fejl i fil")
End If
End If
newvarenr.getnr(1)
End Sub
End Class
-----------------------------------------------------------------
Imports System.IO
Public Class FindVarenr
Public state As String
Public type As String
Public varenr As String
Public Sub getnr(ByVal id As Integer)
Dim strfilename As String
Dim num_rows As Long
Dim num_cols As Long
Dim x As Integer
Dim y As Integer
Dim strarray(1, 1) As String
' Load the file.
state = "File is loading"
strfilename = "C:\Documents and Settings\Kim Almind Pedersen\Skrivebord\Qumec konfigurator\Varenr Generator\" & type
'Check if file exist
If File.Exists(strfilename) Then
Dim tmpstream As StreamReader = File.OpenText(strfilename)
Dim strlines() As String
Dim strline() As String
Dim lines As New List(Of String)(IO.File.ReadAllLines("C:\Documents and Settings\Kim Almind Pedersen\Skrivebord\Qumec konfigurator\Varenr Generator\" & type))
strlines = tmpstream.ReadToEnd().Split(Environment.NewLine)
' Redimension the array.
num_rows = UBound(strlines)
strline = strlines(0).Split(",")
num_cols = UBound(strline)
ReDim strarray(num_rows, num_cols)
strarray(x, y) = strline(y)
varenr = strarray(0, 0)
If varenr = ("") Then
MsgBox("Ikke flere Varenummere")
state = ("ikke flere Varenummere")
Else
Form1.TextBox2.Text = varenr
state = ("Varenummer Fundet")
tmpstream.Close()
'Sletter første linie i filen
lines.RemoveAt(0)
IO.File.WriteAllLines("C:\Documents and Settings\Kim Almind Pedersen\Skrivebord\Qumec konfigurator\Varenr Generator\" & type, lines.ToArray())
End If
End If
End Sub
End Class