View Single Post
  #4 (permalink)  
Old 01-22-2010, 01:35 PM
agraham's Avatar
agraham agraham is online now
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Good habits are best established early in programming (as in life!)

I haven't changed your actual code at all but look how the use of tabs to indent lines reveals the structure in the code and makes it easier to read, particularly when you have nested constructs like Sub/End Sub, If/End If, For/Next, Do/While. You can adjust the amount of indent in the IDE for each tab character by Tools -> IDE Options -> TabSize

Code:
Sub headortail
   a=ComboBox1.Text
   b = TextBox1.Text
   c = Num1.Text
   e=
Cos(((a*10)-b)*(22/(7*180)))*c
   
If  Round(e)<0 Then
      Label11.FontColor= cRed
      Label2.FontColor= cRed
      
Return "TAIL"
   
Else If Round(e)=0 Then
      
Return " "
   
Else
      Label11.FontColor= cBlack
      Label2.FontColor= cBlack
      
Return "HEAD"
   
End If
End Sub
Another tip. Unless you need to return a string with a space character as in the code above you can just use Return on it's own which does in fact return an empty string.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote