Results 1 to 5 of 5

Thread: VBCode formatting

  1. #1

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    VBCode formatting

    VB Code:
    1. x = 0 'initial value
    2.  
    3. Do
    4.     x = x + 1
    5.     Select Case x
    6.       Case 2
    7.           'what to do when x is 2
    8.        Case 10
    9.           'what to do when x is 10
    10.        Case 500
    11.           'what to do when x is 500
    12.      End Select
    13.      DoEvents
    14. Loop
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  2. #2
    ex-Administrator brad jones's Avatar
    Join Date
    Nov 2002
    Location
    Indianapolis
    Posts
    6,614

    Re: VBCode formatting

    Don't use tags within your code. The (Indent) tag is messing up the color coding. Use spaces is my recommendation.

    Brad!
    Have you given out your reputation points today? Select the Rate This Post link to give points for good posts!
    -------------------------------------------------------------
    Brad! Jones
    Lots of Software, LLC
    (I wrote: C Programming in One Hour a Day) (Dad Jokes Book) (Follow me on Twitter)

    --------------------------------------------------------------

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VBCode formatting

    This is what I get when I copy and paste my code straight from VB. Seems like it's missing tabs or newline characters, cause it's suppose to be perfectly even:

    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

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: VBCode formatting

    If you indent blank lines (like VB/most IDEs do by default) then that sometimes gets carried over onto the next line. You need to remove the unnecessary spaces.

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

    Re: VBCode formatting

    Apparently they fixed the problem cause it looks even now.

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