I have a very small VS 2010 app that basically reads the records of a text file, adds some additional information to the end of the record read, and writes the new record to a new text file.
The issue I’m having is with the Left() function. I need to take all chars left of position 10 of a text box and add it to the end of the new record before I write it.
When I use the Left() the “Error List” shows an error related to this function.
The error says:
‘Public Property Left As Integer’ has no parameters and its return type can’t be indexed.
It gives two solutions: 1) Generate Method Stub ‘Left’ in Project1.Form1 and 2) Generate Property Stub ‘Left’
When I select solution 1) that creates a warning indicating: Function ‘Left’ conflicts with property ‘Left’
in the base class ‘Control’ and should be declared ‘Shadows’.
When I select solution 2) that creates a warning indicating: Property ‘Left’ shadows an overloadable member declared in the base class ‘Control’.
If you want to overload the base method, this method must be declared ‘Overloads’.
If anyone could help me out I’d appreciated it.
Here is the code:
Public Class frmProcessFile
Private Sub cmdProcessFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Dim szInRow As String
Dim szOutRow As String
Dim szEmpGroup As String
Using MyFile As New FileIO.TextFieldParser(txtInFile.Text)
MyFile.TextFieldType = FileIO.FieldType.Delimited
While Not MyFile.EndOfData
szInRow = MyFile.ReadLine
szEmpGroup = Left(txtEmp.Text, 10)
szOutRow = szInRow & "PROCESSES COMPLETED ON " & CDate(Today) & vbCrLf
My.Computer.FileSystem.WriteAllText("EXP-" & txtInFile.Text, szOutRow, True)
Here is the code generated when I select solution 1:
Private Function Left(ByVal p1 As String, ByVal p2 As Integer) As String
Throw New NotImplementedException
Here is the code generated when I select solution 2:
Private _left As String
Private Property Left(ByVal p1 As String, ByVal p2 As Integer) As String
Set(ByVal value As String)
_left = value