Results 1 to 2 of 2

Thread: Code copied from VB to Notepad

  1. #1

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Code copied from VB to Notepad

    Seems VBForums has issues when I copy and paste code straight from VB, especially with missing tabs or newlines.:

    VB Code:
    1. Option Explicit
    2.  
    3. Public Function Calculate_Angle(X1 As Single, Y1 As Single, X2 As Single, Y2 As Single) As Single
    4.    
    5.     Const PI As Single = 3.141592654
    6.    
    7.     Dim DX As Single, DY As Single
    8.     Dim Angle As Single
    9.  
    10.         DX = X2 - X1
    11.         DY = Y2 - Y1
    12.        
    13.         Angle = 0
    14.  
    15.         If DX = 0 Then
    16.        
    17.             If DY = 0 Then
    18.            
    19.                 Angle = 0
    20.                
    21.             ElseIf DY > 0 Then
    22.            
    23.                 Angle = PI / 2
    24.            
    25.             Else
    26.                
    27.                 Angle = PI * 3 / 2
    28.                
    29.             End If
    30.        
    31.         ElseIf DY = 0 Then
    32.  
    33.             If DX > 0 Then
    34.            
    35.                 Angle = 0
    36.                
    37.             Else
    38.            
    39.                 Angle = PI
    40.            
    41.             End If
    42.        
    43.         Else
    44.        
    45.             If DX < 0 Then
    46.            
    47.                 Angle = Atn(DY / DX) + PI
    48.                
    49.             ElseIf DY < 0 Then
    50.            
    51.                 Angle = Atn(DY / DX) + (2 * PI)
    52.                
    53.             Else
    54.            
    55.                 Angle = Atn(DY / DX)
    56.                
    57.             End If
    58.            
    59.            
    60.         End If
    61.  
    62.         Angle = Angle * 180 / PI
    63.  
    64.         Calculate_Angle = Angle
    65.  
    66. End Function
    67.  
    68. Private Sub Form_Activate()
    69.  
    70.     AutoRedraw = True
    71.     ScaleMode = 3
    72.     BackColor = RGB(0, 0, 0)
    73.    
    74.     Circle (Me.ScaleWidth / 2, Me.ScaleHeight / 2), 50, RGB(0, 255, 0)
    75.    
    76. End Sub
    77.  
    78. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    79.    
    80.     Dim Angle As Single
    81.    
    82.     Angle = Calculate_Angle(Me.ScaleWidth / 2, Me.ScaleHeight / 2, X, Y)
    83.    
    84.     Me.Caption = Angle
    85.  
    86. End Sub

  2. #2

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Code copied from VB to Notepad

    Well that didn't work. Might as well upload this then:
    Attached Files Attached Files

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