Results 1 to 6 of 6

Thread: QBasic to VB .NET Translation

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2003
    Posts
    17

    QBasic to VB .NET Translation

    Here's the QB Code. I tried to translate it to VB .NET Console code. See translated code below
    PHP Code:
    CLS
    L1
    % = 0X1% = 0X2% = 0X3% = 0
    LOCATE 2
    1
    PRINT "Enter name";
    Sw1% = 1
    WHILE Sw1% = 1
        INPUT A
    $
        
    L1% = LEN(A$)
        FOR 
    X1% = 1 TO L1%
            
    X2% = ASC(MID$(A$, X1%, 1))
            IF 
    X2% > 90 THEN X2% = X2% - 32
            X2
    % = X2% - 64
            X2
    % = X2% * 6
            X3
    % = X3% + X2%
        
    NEXT X1%
        
    LOCATE 41
        
    PRINT A$; " = "X3%
        
    B$ = ""
        
    WHILE B$ = ""
            
    B$ = INKEY$
        
    WEND
        LOCATE 6
    1
        
    PRINT "Again?"
        
    B$ = ""
        
    WHILE B$ = ""
            
    B$ = INKEY$
        
    WEND
        
    IF B$ <> "Y" AND B$ <> "y" THEN
            Sw1
    % = 0
        
    ELSE
            
    L1% = 0X1% = 0X2% = 0X3% = 0
            A
    $ = ""B$ = ""
            
    CLS
            LOCATE 2
    1
            
    PRINT "Enter name";
        
    END IF
    WEND
    CLS
    LOCATE 2
    1
    PRINT "Thank you for using 666 Searcher."
    END 
    Here's my code after translating. But somehow I stuck and it doesn't work:
    VB Code:
    1. Module Module1
    2.  
    3.     Sub Main()
    4.         Dim L1 As Int16 = 0
    5.         Dim X1 As Int16 = 0
    6.         Dim X2 As Int16 = 0
    7.         Dim X3 As Int16 = 0
    8.         Dim INKEY As String
    9.         'dim LOCATE as Int16 (2, 1)
    10.         Console.WriteLine("Enter name")
    11.         Dim Sw1 As Int16 = 1
    12.         While Sw1 = 1
    13.             Dim A As String
    14.             Console.Read(A)
    15.             L1 = Len(A.ToString())
    16.             For X1 = 1 To L1
    17.                 X2 = Asc(Mid(A, X1, 1))
    18.                 If X2 > 90 Then X2 = X2 - 32
    19.                 X2 = X2 - 64
    20.                 X2 = X2 * 6
    21.                 X3 = X3 + X2
    22.             Next X1
    23.             'LOCATE(4, 1)
    24.             Console.WriteLine(A + " = " + X3)
    25.             Dim B As String = ""
    26.             While B = ""
    27.                 B = INKEY
    28.             End While
    29.             'LOCATE(6, 1)
    30.             Console.WriteLine("Again?")
    31.             B = ""
    32.             While B = ""
    33.                 B = INKEY
    34.             End While
    35.             If B <> "Y" And B <> "y" Then
    36.                 Sw1 = 0
    37.             Else
    38.                 L1 = 0 : X1 = 0 : X2 = 0 : X3 = 0
    39.                 A = "" : B = ""
    40.                 'LOCATE(2, 1)
    41.                 Console.WriteLine("Enter name")
    42.             End If
    43.         End While
    44.         'LOCATE(2, 1)
    45.         End
    46.  
    47.     End Sub
    48.  
    49. End Module

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Dude , QBasic days had gone .

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What is this code suppose to do?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I think this MAY be what you are after:
    VB Code:
    1. Module Module1
    2.  
    3.     Sub Main()
    4.         Console.WriteLine("Enter name:")
    5.         Dim ret As String = Console.ReadLine
    6.         Console.WriteLine(ret & " = " & Encrypt(ret))
    7.         Console.WriteLine("Again?")
    8.         ret = Console.ReadLine
    9.         If ret.ToLower = "y" Then
    10.             'have method call itself to repeat
    11.             Main()
    12.         End If
    13.     End Sub
    14.  
    15.     Public Function Encrypt(ByVal normal As String) As String
    16.         Dim cnt As Integer
    17.         'the string's 1st char is at 0
    18.         'so we start at 0 and go 1 short of the length
    19.         Dim cntMax As Integer = normal.Length - 1
    20.         'this handles an errors as a result of a blank string
    21.         If cntMax < 0 Then cntMax = 0
    22.         Dim result As String
    23.         For cnt = 0 To cntMax
    24.             Dim tmp As Integer = Asc(normal.Substring(cnt, 1))
    25.             If tmp > 90 Then tmp = tmp - 32
    26.             tmp = tmp - 64
    27.             tmp = tmp * 6
    28.             result &= tmp
    29.         Next
    30.         Return result
    31.     End Function
    32.  
    33. End Module

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2003
    Posts
    17
    See this site:
    http://www.theforbiddenknowledge.com...des/words.html

    That's what the code is supposed to do.

    @ Pirate:
    I know that. See that site. That's why I wanna translate it!

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You ever hear of the spanish inquisition? Any way using what I posted and the code you have you should be able to figure it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width