I am working in Visual Basic to create code that includes a special message for parts depending on if an excel file indicates they need it. The excel file consists of 3 columns: characters a part may start with, contain, or end with. The code needs to detect if the part starts with a character combination included in the "starts with" column, contains one from the contains column, or ends with one from the ends with column, and if it does then the corresponding message to those specifications will be displayed elsewhere in the code.
To get the data out of the excel (csv) file I use a streamreader and put each column into an array as follows:
Dim SData() As String
Dim SWith, Contain, EWith, Message As New List(Of String)()
Using sr As New StreamReader("L:\Mfg-Eng\SystemID\DOWNLOADS\SCSpecialNotes.csv")
While Not sr.EndOfStream
SData = sr.ReadLine().Split(","c)
I am new to visual basic, and I am having trouble coming up with an "If" statement to follow the creation of these arrays in which the statement executes code when the string in question (not written in above code, I'll refer to it as "partID") starts with any member of the "SWith" array, or ends with any member of the "EWith" array.
What I have tried:
I have tried creating a separate string to utilize the "Contains" method for searching the array in which the If statement executs when the partID starts with a string that the SWith array contains, but this doesn't work when I haven't given the placeholder string a value, and feels like a cumbersome and confusing way to tackle this. I have searched extensively online for a way to write this code but I have been unable to find one, and I am very new to using Visual Basic and its commands. Any help is greatly appreciated.