troubleshooting Question

Loop fot this

Avatar of Ilianam
Ilianam asked on
Visual Basic.NET
9 Comments1 Solution226 ViewsLast Modified:
I have this
myCommand = New SqlClient.SqlCommand("MDAddClaimServiceDates", myConnection)
                    myCommand.CommandType = CommandType.StoredProcedure
                    With myCommand
                        .Parameters.Add("@DenialID", SqlDbType.Int)
                        .Parameters.Add("@SrvcStartDt", SqlDbType.SmallDateTime)
                        .Parameters.Add("@SrvcEndDt", SqlDbType.SmallDateTime)
                        .Parameters.Add("@SrvcDateID", SqlDbType.Int)
                        .Parameters("@DenialID").Value = DenialID
                        .Parameters("@SrvcStartDt").Value = txtService1.Text
                        .Parameters("@SrvcEndDt").Value = txtService1.Text
                        .Parameters("@SrvcDateID").Direction = ParameterDirection.Output

                        .ExecuteNonQuery()
                        ServiceID = (.Parameters("@SrvcDateID").Value)
                        If txtCPT1.Text <> "" Then
                            myCommand = New SqlClient.SqlCommand("MDAddClaimService", myConnection)
                            myCommand.CommandType = CommandType.StoredProcedure
                            With myCommand
                                .Parameters.Add("@DenialID", SqlDbType.Int)
                                .Parameters.Add("@SrvcDateID", SqlDbType.Int)
                                .Parameters.Add("@CptRevCd", SqlDbType.NVarChar)
                                .Parameters("@DenialID").Value = DenialID
                                .Parameters("@SrvcDateID").Value = ServiceID
                                .Parameters("@CptRevCd").Value = txtCptRev1.Text
                                .ExecuteNonQuery()

                            End With
I need to repeat the same code for 6 diferent textboxes, i.e: txtService2....txtService6
Is there a way to put the sme code within a for loop?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 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 9 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