EDN Admin
Well-known member
Im getting 2 errors:
Variable Wgt2 hides a variable in an enclosing block
Variable Wgt1 hides a variable in an enclosing block
From what i understand, this error means Im declaring a variable twice (is this correct?).
Also, the strange part is, the error doesnt pop up until i typed in the last line of code for the message box to display the contents of these 2 variables.
Can anyone offer some insight?
TIA!
Joni
<pre class="prettyprint lang-vb Dim MainMN As String = ("M:scbmainemain" & Wave & "" & File1)
Dim MainRdr As StreamReader
MainRdr = File.OpenText(MainMN)
Dim MainMN2 As String = ("M:scbmainemain" & Wave & "" & File2)
Dim Main2Rdr As StreamReader
Main2Rdr = File.OpenText(MainMN2)
Dim RAfile As String = ("M:OLTAPE" & MKT & Rel & YEARcurrent & "RA.tmp")
Dim RArdr As StreamReader
RArdr = File.OpenText(RAfile)
Dim TVthv As String = ("M:scbmainemain" & Wave & "" & MKT & Rel & YEARcurrent & "tv.thv")
Dim TvRdr As StreamReader
If System.IO.File.Exists(TVthv) = True Then
TvRdr = File.OpenText(TVthv)
Else
MsgBox("******** TV HEAVINESS FILE (" & MKT & Rel & YEARcurrent & "TV.THV) DOES NOT EXIST!")
cmdRUN.Enabled = True
Exit Sub
End If
Dim QUo02 As String = "M:SCBMAINQUINTILE" & Rel & YEARcurrent & "" & MKT & Rel & YEARcurrent & "QU.o02"
Dim QUo02Wrtr As StreamWriter
QUo02Wrtr = System.IO.File.CreateText(QUo02)
Dim MainCounter As Long = 0
Dim TotalWeight As Long = 0
Do While MainRdr.Peek() >= 0
Dim MainRec As String = MainRdr.ReadLine
Dim NpRec As String = Main2Rdr.ReadLine
Dim RArec As String = RArdr.ReadLine
Dim TVrec As String = TvRdr.ReadLine
Dim MThev As String = "0" & MainRec.Substring(132, 1)
Dim InternetHev As String = "0" & MainRec.Substring(160, 1)
Dim ID As String = MainRec.Substring(0, 6)
Dim Wgt2 As String = MainRec.Substring(7, 5)
Dim MallHev As String = MainRec.Substring(136, 4)
Dim TVhev As String = TVrec.Substring(34, 3)
Dim ENhev As String = MainRec.Substring(300, 2)
Dim Digital1 As String = MainRec.Substring(322, 2)
Dim Digital2 As String = MainRec.Substring(320, 2)
Dim Wgt2int As Long = Long.Parse(Wgt2) converts string to integer
Dim Wgt1int As Long
If optSyndicated.Checked = True Then
Wgt1int = Wgt2int / 2
Else
Wgt1int = Wgt2int * 2
End If
Dim Wgt1 As String = Format(Wgt1int, "00000")
Wgt2 = Format(Wgt2, "00000")
Loop
MainRdr.Close()
Main2Rdr.Close()
RArdr.Close()
TvRdr.Close()
MsgBox(wgt1 & vbCrLf & wgt2)[/code]
<br/>
<hr class="sig -Joni
View the full article
Variable Wgt2 hides a variable in an enclosing block
Variable Wgt1 hides a variable in an enclosing block
From what i understand, this error means Im declaring a variable twice (is this correct?).
Also, the strange part is, the error doesnt pop up until i typed in the last line of code for the message box to display the contents of these 2 variables.
Can anyone offer some insight?
TIA!
Joni
<pre class="prettyprint lang-vb Dim MainMN As String = ("M:scbmainemain" & Wave & "" & File1)
Dim MainRdr As StreamReader
MainRdr = File.OpenText(MainMN)
Dim MainMN2 As String = ("M:scbmainemain" & Wave & "" & File2)
Dim Main2Rdr As StreamReader
Main2Rdr = File.OpenText(MainMN2)
Dim RAfile As String = ("M:OLTAPE" & MKT & Rel & YEARcurrent & "RA.tmp")
Dim RArdr As StreamReader
RArdr = File.OpenText(RAfile)
Dim TVthv As String = ("M:scbmainemain" & Wave & "" & MKT & Rel & YEARcurrent & "tv.thv")
Dim TvRdr As StreamReader
If System.IO.File.Exists(TVthv) = True Then
TvRdr = File.OpenText(TVthv)
Else
MsgBox("******** TV HEAVINESS FILE (" & MKT & Rel & YEARcurrent & "TV.THV) DOES NOT EXIST!")
cmdRUN.Enabled = True
Exit Sub
End If
Dim QUo02 As String = "M:SCBMAINQUINTILE" & Rel & YEARcurrent & "" & MKT & Rel & YEARcurrent & "QU.o02"
Dim QUo02Wrtr As StreamWriter
QUo02Wrtr = System.IO.File.CreateText(QUo02)
Dim MainCounter As Long = 0
Dim TotalWeight As Long = 0
Do While MainRdr.Peek() >= 0
Dim MainRec As String = MainRdr.ReadLine
Dim NpRec As String = Main2Rdr.ReadLine
Dim RArec As String = RArdr.ReadLine
Dim TVrec As String = TvRdr.ReadLine
Dim MThev As String = "0" & MainRec.Substring(132, 1)
Dim InternetHev As String = "0" & MainRec.Substring(160, 1)
Dim ID As String = MainRec.Substring(0, 6)
Dim Wgt2 As String = MainRec.Substring(7, 5)
Dim MallHev As String = MainRec.Substring(136, 4)
Dim TVhev As String = TVrec.Substring(34, 3)
Dim ENhev As String = MainRec.Substring(300, 2)
Dim Digital1 As String = MainRec.Substring(322, 2)
Dim Digital2 As String = MainRec.Substring(320, 2)
Dim Wgt2int As Long = Long.Parse(Wgt2) converts string to integer
Dim Wgt1int As Long
If optSyndicated.Checked = True Then
Wgt1int = Wgt2int / 2
Else
Wgt1int = Wgt2int * 2
End If
Dim Wgt1 As String = Format(Wgt1int, "00000")
Wgt2 = Format(Wgt2, "00000")
Loop
MainRdr.Close()
Main2Rdr.Close()
RArdr.Close()
TvRdr.Close()
MsgBox(wgt1 & vbCrLf & wgt2)[/code]
<br/>
<hr class="sig -Joni
View the full article