USING: VB.Net 2005 SP1, Compact Framework 2.0, MS SQL Server 2005 Compact Edition
I have a textbox that has to be at minimum 1 character long. In it a user will type a product code. Based on a data field called t_len determines how many continous sections of the same product there should be. I can not figure out how to do this.
if txtProduct.text = 'QQQLZVBBL' - each character represents a product segment. If t_len for Q is set to 1 then this would be ok because it has 3 continous sections. Also if t_len for Q had been 2 or 3 it would have been acceptable because the minimum had been met.
But suppose if t_len for L is 2 it would fail because there should be LL as there must be 2 continous sections of L to be valid. Also note that there is a second L but it is not beside the first L therefore both fail and product code is not acceptable.
So it has to go through some sort of counter loop. I have been able to isolate each character but can not for the life of me come up with the logic to capture missed sections. Please help. See my code below thus far.
Dim X as Integer
Dim xPROD As Integer
For xPROD = 0 To txtProduct.TextLength - 1
strProd = txtProduct.Text.Substring(xPROD, 1)
Dim ssceconn As New SqlCeConnection("Data Source = \Program Files\data\" & Trim(Me.Text) & "\products\" & [strSpec])
Dim readerCT As SqlCeDataReader
Dim cmdCT As New SqlCeCommand("SELECT t_len FROM prod WHERE t_code = '" & [strProd] & "'", ssceconn)
readerCT = cmdCT.ExecuteReader
X = readerCT.Item("t_len).toString 'guaranteed to only be 1 record. THIS IS WHERE I GOT STUCK. Now that I have the min sections I do not know how to apply the value to the rest of the txtProduct.Text to see if requirements are met
readerCT = Nothing