Need help with VB.NET List Logic -


Hey guys, so I'm making a list (string), always size 9.

This list contains true / false values ​​I need to go through this list and find 3 values ​​which are true (more than 3 but can be less) and then In my code, set 3 string value in 3 index of those three values.

Here is my current code:

  Private Sub SetDenialReasons (ByVal LoanData as DataRow) New list (as the string) causes reasons with diminishes. Add (Loyndtakaitm ( "Isdnialreasndti") Ktostring) Kaed (Loyndtakaitm ( "Isdnialrasonemploymenthistori"). Tostring) Kaed (Loyndtakaitm ( "Isdnialreasnkreditistory"). Tostring) Kaed (Loyndtakaitm ( "Isdnialreasnklterl" ). ToString) KAdd (LoanData. ( "Insdeniyl Riesen cache") Tostring. add (Londatakaitm ( "Insdeniyl Reason Inverfeabl Info"). Tostring) (Londatakaitm ( "Insdeniyl region Anum Pt ") Tustring) Kjoden (loan survived. Item (" Insdeniyl Region Mortgage Insurance Dinid "). ToString). Add (Londatakitm (" Insdeniyl Riesen Author "). Tustring) each item as dim count Integer = 0 finished with the reasons for the string item = "true" then count + = 1 end if Next then count = 1 then DenialReason1 = (reasons.IndexOf ( "right") + 1) .ToString elseif count = 2 then DenialReason1 = (reasons.IndexOf ("right") + 1) .String DenialReason2 = (reasons.LastIndexOf ("true") + 1) .ToString elseif count & gt; = 3 then dim tempIndex int = .IndexOf as causes ( "Right") DenialReason1 = (reasons.IndexOf ( "right") + 1) .ToString DenialReason2 = (reasons.IndexOf ( "right", tempIndex, reasons.Count - 1) +1) .ToString DenialReason3 = (For reasons. List index ("True") + 1). Stressing and if end all  

I have 3 truths that are related to each other Are beside and the code has failed with an exception. Positive or something else

Now if less than 3 is true, this shu

any thoughts?

Perhaps you can modify your each code to handle the assignment of DenialReason s. It still feels like a hack, but I think it can be clear what you have. If you use this code, you do not need the code, which starts with = 1 ... :

  Slow number as integer = 0 dim index int = 1 each item for the reasons as string items = "true" then select + = 1 episode count case 1 DenialReason1 = index.ToString () case 2 DenialReason2 = Index.ToString () Case 3 DenialReason3 = index.ToString (Count) End End Index Index + = 1 Next  

Above Indexes variable a 1-based index to admit I think it indexOf () .

is clear from the use. I think a better solution could be that the list of DenialReason s be added and add it as the list is true:

  deferred as integer Calculate integer = 0 dim as integer = 1 dim rejection New list (in the form of string) causes (as the string) for each item in the form of the string if the item = "true" then denialReasons.Add (index) End if index = = 1 next  

then you just list your IalReasons can iterate through. It is flexible so if, for any reason, you have more than three DenialReason s, you do not need to add any other hard-coded variable.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -