Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB -> C#: Comparison of ComboBox.ObjectCollection.Item with integer value #1167

Closed
RDH1066 opened this issue Feb 4, 2025 · 1 comment
Closed
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@RDH1066
Copy link

RDH1066 commented Feb 4, 2025

VB.Net input code

  For lCount = 0 To cbMWST.Items.Count - 1
                
                If cbMWST.Items(lCount).Item(0) = m_lDefault_MWSTID Then

                    cbMWST.SelectedValue = m_lDefault_MWSTID

                    Exit For
                End If

            Next

... 

Erroneous output

  for (int lCount = 0, loopTo = cbMWST.Items.Count - 1; lCount <= loopTo; lCount++)
                {  
                    if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(((dynamic)cbMWST.Items[lCount]).Item(0), m_lDefault_MWSTID, false)))
                    {
                        cbMWST.SelectedValue = m_lDefault_MWSTID;

                        break;
                    }
                }

Expected output

 for (int lCount = 0, loopTo = cbMWST.Items.Count - 1; lCount <= loopTo; lCount++)
                {
                    if (int.Parse(((ComboBox.ObjectCollection)cbMWST.Items[lCount])[0].ToString()) == m_lDefault_MWSTID)
                    {
                            cbMWST.SelectedValue = m_lDefault_MWSTID;
                             break;
                    }
                }
...

Details

  • Product in use: VS extension / Microsoft Visual Studio Professional 2022 (2) (64-Bit)
  • Version in use: 9.2.6.0 / 17.12.4
@RDH1066 RDH1066 added the VB -> C# Specific to VB -> C# conversion label Feb 4, 2025
@GrahamTheCoder
Copy link
Member

I can't tell 100% without the context that defines cbMWST, but this looks like a late bound method call. There's no way for the converter to guess what type cbMWST is.
If you define cbMWST As ComboBox.ObjectCollection in the VB, then this will convert fine.
Covered by #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants