troubleshooting Question

Need help with counter loop comparing portions of text in texbox against a value in a datbase

Avatar of PBLack
PBLack asked on
.NET ProgrammingVisual Basic.NETMicrosoft SQL Server 2005
4 Comments1 Solution278 ViewsLast Modified:
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.

For example:

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

            While readerCT.Read
               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
            End While

            readerCT = Nothing
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros