locked
C# to VB RRS feed

  • Question

  • User1602376834 posted

    I need some help converting few statements fro m C# to VB

    public ConditionStream(string condition, FullTextSearchOptions options)
                {
                    this.options = options;
                    this.condition = Regex.Replace((condition ?? String.Empty), @"\x09|\x0D|\x0A|[\x01-\x08]|\x10|[\x0B-\x0C]|[\x0E-\x1F]", " ");
                    index = -1;
                }



    while (stream.Read())
                    {
                        if (ConditionOperator.IsSymbol(stream.Current))
                        {
                            PutToken();
                            SetToken(stream.Current);
                            PutToken();
                            continue;
                        }
                        switch (stream.Current)
                        {
                            case ' ': PutToken(); continue;
                            case '(': Push; continue;
                            case ')': Pop(); continue;
                            case '"':
                                PutToken();
                                inQuotes = true;
                                SetToken(stream.ReadQuote());
                                PutToken();
                                inQuotes = false;
                                continue;
                        }
                        AddToken(stream.Current);
                    }


    Tuesday, January 18, 2011 7:51 PM

Answers

  • User397347636 posted
    'INSTANT VB WARNING: The following constructor is declared outside of its associated class:
    'ORIGINAL LINE: public ConditionStream(string condition, FullTextSearchOptions options)
    Public Sub New(ByVal condition As String, ByVal options As FullTextSearchOptions)
    	Me.options = options
    	Me.condition = Regex.Replace((If(condition, String.Empty)), "\x09|\x0D|\x0A|[\x01-\x08]|\x10|[\x0B-\x0C]|[\x0E-\x1F]", " ")
    	index = -1
    End Sub


     

    Do While stream.Read()
    	If ConditionOperator.IsSymbol(stream.Current) Then
    		PutToken()
    		SetToken(stream.Current)
    		PutToken()
    		Continue Do
    	End If
    	Select Case stream.Current
    		Case " "c
    			PutToken()
    			Continue Do
    		Case "("c
    			Push
    			Continue Do
    		Case ")"c
    			Pop()
    			Continue Do
    		Case """"c
    			PutToken()
    			inQuotes = True
    			SetToken(stream.ReadQuote())
    			PutToken()
    			inQuotes = False
    			Continue Do
    	End Select
    	AddToken(stream.Current)
    Loop


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 25, 2011 11:05 AM

All replies

  • User-2110079211 posted

    wow.. thats lot of HTML you are trying spit out from the code. It is old classic ASP style. Anyway check this link http://converter.telerik.com/ it might help you. 

    Tuesday, January 18, 2011 8:36 PM
  • User988538322 posted

    You also can use this 

    http://www.developerfusion.com/tools/convert/vb-to-csharp/

    Tuesday, January 25, 2011 12:14 AM
  • User397347636 posted
    'INSTANT VB WARNING: The following constructor is declared outside of its associated class:
    'ORIGINAL LINE: public ConditionStream(string condition, FullTextSearchOptions options)
    Public Sub New(ByVal condition As String, ByVal options As FullTextSearchOptions)
    	Me.options = options
    	Me.condition = Regex.Replace((If(condition, String.Empty)), "\x09|\x0D|\x0A|[\x01-\x08]|\x10|[\x0B-\x0C]|[\x0E-\x1F]", " ")
    	index = -1
    End Sub


     

    Do While stream.Read()
    	If ConditionOperator.IsSymbol(stream.Current) Then
    		PutToken()
    		SetToken(stream.Current)
    		PutToken()
    		Continue Do
    	End If
    	Select Case stream.Current
    		Case " "c
    			PutToken()
    			Continue Do
    		Case "("c
    			Push
    			Continue Do
    		Case ")"c
    			Pop()
    			Continue Do
    		Case """"c
    			PutToken()
    			inQuotes = True
    			SetToken(stream.ReadQuote())
    			PutToken()
    			inQuotes = False
    			Continue Do
    	End Select
    	AddToken(stream.Current)
    Loop


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 25, 2011 11:05 AM
  • User397347636 posted

     

    Problem is that the conversion from this source targets an unknown version of VB which has a "Continue Select" statement.

     

    Tuesday, January 25, 2011 11:10 AM
  • User42903263 posted

    And also, "\x09|\x0D|\x0A|[\x01-\x08]|\x10|[\x0B-\x0C]|[\x0E-\x1F]" is surely the same as "[\x01-\x1F]"?

    --
    Andrew

    Tuesday, January 25, 2011 5:58 PM
  • User397347636 posted

    As I mentioned a few months ago - that is not VB code - VB has no "Continue Select".

    Again, it's worth mentioning that the online converters are not actively maintained and will often produce strange results such as this.

    Friday, May 13, 2011 10:30 AM