i commenti si identificano da (') o (_). Se una riga inizia con uno di questi due caratteri allora è sicuramente un commento.
se il carattere apice (') è contenuto in una stringa di testo allora non è un commento, se non lo è tutto quello che viene dopo è sicuramente un commento.

prova con questo...

codice:
    Dim Record As String
    Dim TestoSiNo As Boolean
    Dim InizioStringa As Integer
    Dim StringaOutput As String
    Dim i As Integer
    
    Open "xxx.bas" For Input As #1
    Open "xxx_test.bas" For Output As #2
    
    While Not EOF(1)
        Line Input #1, Record
        InizioStringa = Len(Record) - Len(LTrim(Record)) + 1
        
        TestoSiNo = False
        StringaOutput = ""
        For i = 1 To Len(Record)
            If i < InizioStringa Then
                StringaOutput = StringaOutput & " "
            Else
                Select Case Mid(Record, i, 1)
                    Case "_": If i = InizioStringa Then Exit For
                    Case "'": If TestoSiNo = False Then Exit For
                    Case """": TestoSiNo = Not (TestoSiNo)
                End Select
                StringaOutput = StringaOutput & Mid(Record, i, 1)
            End If
        Next i
        Print #2, StringaOutput
    Wend
    Close