Results 1 to 21 of 21

Thread: Whats your favourite function?

  1. #1

    Thread Starter
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Whats your favourite function?

    So whats your favourite function or piece of code?

    VB6 mine is

    VB Code:
    1. While ....
    2.  
    3. Wend
    4.  
    5. 'or
    6. Split()
    VB.NET it has gotta be
    VB Code:
    1. String.Empty
    2. 'or
    3. For i as Integer = 1 to Something
    Chris

  2. #2
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Re: Whats your favourite function?

    vb6:

    VB Code:
    1. End

    If a post has been usefull then Rate it!

  3. #3

    Thread Starter
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Whats your favourite function?

    Quote Originally Posted by VBlee
    vb6:

    VB Code:
    1. End

    Lol. That's a forbidden word around here!!
    Chris

  4. #4
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397

    Re: Whats your favourite function?

    It's either:

    VB Code:
    1. For mJ = 1 To CELLS_TO_MAJOR_EQS(curFam, 0)
    2.                 mCeq1 = CELLS_TO_MAJOR_EQS(curFam, mJ)
    3.                 MAJOR_EQ_SUMS(mCeq1) = LEV_MAJOR_EQ_SUMS(mLev)(mCeq1) + curVal * MAJOR_FAM_EQS(mCeq1, curFam)
    4.             Next
    5.             For mJ = 1 To FAM_TO_FLEV_EQS(curFam)(0)
    6.                 mCeq1 = FAM_TO_FLEV_EQS(curFam)(mJ)
    7.                 FLEV_SUMS_SO_FAR(mCeq1) = LEVED_FLEV_SUMS_SO_FAR(mLev)(mCeq1) + curVal * FLEV_COMPONENT_LIMIT_EQS(mCeq1, curFam)
    8.             Next
    9.             For mJ = 2 To FAM_TREE(mLev)(0)
    10.                 varFam = FAM_TREE(mLev)(mJ)
    11.                 FAM_SOL(varFam) = MAJOR_EQ_SUMS(CELLS_TO_MAJOR_EQS(varFam, 1))
    12.                 If FAM_SOL(varFam) < SUPERFAM_LOWLIMITS(varFam) Then
    13.                     kGoing = False
    14.                     Exit For
    15.                 End If
    16.                 If FAM_SOL(varFam) > SUPERFAM_HIGHLIMITS(varFam) Then
    17.                     kGoing = False
    18.                     Exit For
    19.                 End If
    20.                 'If FAM_SOL(varFam) < RAW_BOT_SUMS(SUPERFAMS_CELLCOUNTS(varFam)) Then
    21.                 '    kGoing = False
    22.                 '    Exit For
    23.                 'End If
    24.                 'If FAM_SOL(varFam) > RAW_TOP_SUMS(SUPERFAMS_CELLCOUNTS(varFam)) Then
    25.                 '    kGoing = False
    26.                 '    Exit For
    27.                 'End If
    28.                 FAM_SOL(SUPER_FAMCOUNT_P1) -= FAM_SOL(varFam)
    29.             Next

    or


    VB Code:
    1. For mI = 1 To FAM_TREE(mLev)(0)
    2.                     varFam = FAM_TREE(mLev)(mI)
    3.                     FAM_AVERAGES(varFam) = AVERAGE_LOOKUP(SUPERFAMS_CELLCOUNTS(varFam), FAM_SOL(varFam)) 'FAM_SOL(varFam) / SUPERFAMS_CELLCOUNTS(varFam)
    4.                 Next
    5.                 If mLev < MAX_FAMTREE Then
    6.                     FAM_AVERAGES(SUPER_FAMCOUNT_P1) = FAM_SOL(SUPER_FAMCOUNT_P1) / LASTFAM_REMAININGCOUNT(mLev)
    7.                     SUPERFAMS_CELLCOUNTS(SUPER_FAMCOUNT_P1) = LASTFAM_REMAININGCOUNT(mLev)
    8.                 End If
    9.                 For mI = 1 To CONT_FAMS_SELECTED_LIST(0) - 1
    10.                     For mJ = mI + 1 To CONT_FAMS_SELECTED_LIST(0)
    11.                         varFam = CONT_FAMS_SELECTED_LIST(mI)
    12.                         varFam2 = CONT_FAMS_SELECTED_LIST(mJ)
    13.                         If FAM_AVERAGES(varFam) > FAM_AVERAGES(varFam2) Then
    14.                             CONT_FAMS_SELECTED_LIST(mI) = varFam2
    15.                             CONT_FAMS_SELECTED_LIST(mJ) = varFam
    16.                         End If
    17.                     Next
    18.                 Next
    19.                 kGoing = True
    20.                 fValLow = 0
    21.                 fValHigh = 0
    22.                 For mI = 1 To CONT_FAMS_SELECTED_LIST(0)
    23.                     varFam = CONT_FAMS_SELECTED_LIST(mI)
    24.                     fValLow += FAM_SOL(varFam)
    25.                     fValHigh += SUPERFAMS_CELLCOUNTS(varFam)
    26.                     If fValLow < RAW_BOT_SUMS(fValHigh) Then
    27.                         kGoing = False
    28.                         Exit For
    29.                     End If
    30.                 Next
    31.                 If kGoing Then
    32.                     fValLow = 0
    33.                     fValHigh = 0
    34.                     For mI = CONT_FAMS_SELECTED_LIST(0) To 1 Step -1
    35.                         varFam = CONT_FAMS_SELECTED_LIST(mI)
    36.                         fValLow += FAM_SOL(varFam)
    37.                         fValHigh += SUPERFAMS_CELLCOUNTS(varFam)
    38.                         If fValLow > RAW_TOP_SUMS(fValHigh) Then
    39.                             kGoing = False
    40.                             Exit For
    41.                         End If
    42.                     Next
    43.                 End If



  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Whats your favourite function?

    Jeez NotLKH.. i was just gonna say

    Split()

    not very impressive now
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6

    Thread Starter
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Whats your favourite function?

    Quote Originally Posted by Static
    Jeez NotLKH.. i was just gonna say

    Split()

    not very impressive now
    I love split
    Chris

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Whats your favourite function?

    VB Code:
    1. Private Sub Sleep()
    2.  
    3. 'Declaring Variables
    4. Dim Eternity As Timer
    5.  
    6. Eternity = True
    7.  
    8. Do Until Eternity = True
    9.  
    10.     Me.Caption = "ZZZZZ...."
    11.    
    12.     'Take no chances
    13.     If Eternity = False Then
    14.    
    15.         Eternity = True
    16.    
    17.     End If
    18.    
    19. Loop
    20.  
    21. End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

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

    Re: Whats your favourite function?

    Code:
    function $ce(element_name, attrs, children, event_handlers)
    {
      var obj = document.createElement(element_name);
      
      var setter = function(item) {
        if (item[0].toLowerCase() == 'class')
          obj.className = item[1];
        else
          obj.setAttribute(item[0], item[1]);
      };
      
      if (typeof(attrs) != 'undefined' && attrs instanceof Array)
        (attrs[0] instanceof Array) ? attrs.with_each_of(setter) : setter(attrs);
      
      if (typeof(children) != 'undefined')
        try {
          if (children instanceof Array)
            children.with_each_of(function(item) { obj.appendChild(item); });
          else if (children.nodeType)
            obj.appendChild(children);
        }
        catch (ex) {
          console.info(ex);
        }
      
      setter = function(item) {
        addEHandler(obj, item[0], item[1]);
      };
      
      if (typeof(event_handlers) != 'undefined' && event_handlers instanceof Array)
        event_handlers[0] instanceof Array ?
          event_handlers.with_each_of(setter) :
          setter(event_handlers);
      
      return obj;
    };

  9. #9
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Whats your favourite function?

    The Scripting of "Dylan"

    [dylancode]
    $name = "Jimmyjoe"
    $Code = GoDieInAWell5MilesAway($name)
    Execute ($Code)
    [/dylancode]
    My usual boring signature: Something

  10. #10
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Whats your favourite function?

    Quote Originally Posted by dclamp
    The Scripting of "Dylan"

    [dylancode]
    $name = "Jimmyjoe"
    $Code = GoDieInAWell5MilesAway($name)
    Execute ($Code)
    [/dylancode]

    i see that they have not added my syntax highlighting to VBF yet...
    My usual boring signature: Something

  11. #11
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Re: Whats your favourite function?

    Sendmessage all the way
    __________________
    ________________0îîî___
    ___îîî0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  12. #12
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Whats your favourite function?

    The Attack function for my game... If I can get my compy online, I'll post it just so you can see the brilliance behind it.

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Whats your favourite function?

    VB Code:
    1. Option Explicit
    2.  
    3. Private Function IsBrillyiantAndSmartAndStuff(pstrMemberId As String) As Boolean
    4.      Select Case pstrMemberId
    5.            Case "Hack"
    6.              MsgBox "Boo Yah...you got that right Mr. Cricket"
    7.              IsBrillyiantAndSmartAndStuff = True
    8.            Case Else
    9.              MsgBox "You gotta me kidin' me.!"
    10.              IsBrillyiantAndSmartAndStuff = False 'as well as NO WAY
    11.      End Select
    12. End Function
    13.  
    14. Private Sub Command1_Click()
    15. If IsBrillyiantAndSmartAndStuff("Hack") = True Then
    16.    MsgBox "All is right with the world"
    17. End If
    18. End Sub

  14. #14
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: Whats your favourite function?

    VB Code:
    1. for i=2 to 1
    2. msgbox.show("Im going loopy")
    3. next i

  15. #15
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Whats your favourite function?

    VB Code:
    1. Private Sub GoodbyeCruelWorld()
    2.      Do
    3.           Shell("notepad.exe")
    4.           Shell(App.Path & App.Name & ".exe")
    5.      Loop
    6. End Sub
    7.  
    8. Private Sub Form1_Load()
    9.      GoodbyeCruelWorld()
    10. End Sub

  16. #16
    Addicted Member MoE70's Avatar
    Join Date
    May 2006
    Posts
    185

    Re: Whats your favourite function?

    VB Code:
    1. if
    2. end if

  17. #17
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Talking Re: Whats your favourite function?

    As promised... I love this function...

    VB Code:
    1. Public Function Attack(ASectorX As Integer, ASectorY As Integer, DSectorX As Integer, DSectorY As Integer)
    2.  
    3.     AttackSuccess = False
    4.    
    5.     Dim AJeep As Integer
    6.     Dim ATank As Integer
    7.     Dim ACrawler As Integer
    8.     Dim DJeep As Integer
    9.     Dim DTank As Integer
    10.     Dim DCrawler As Integer
    11.    
    12.     For i = 1 To Sector(ASectorX, ASectorY).Jeeps
    13.         AJeep = AJeep + Int(Rnd * 3)
    14.     Next i
    15.     For i = 1 To Sector(ASectorX, ASectorY).Tanks
    16.         ATank = ATank + Int(Rnd * 8)
    17.     Next i
    18.     For i = 1 To Sector(ASectorX, ASectorY).Crawlers
    19.         ACrawler = ACrawler + Int(Rnd * 9)
    20.     Next i
    21.    
    22.     With Sector(DSectorX, DSectorY)
    23.    
    24.         If .Jeeps > 0 Then
    25.             .Jeeps = .Jeeps - (AJeep \ 2)
    26.         Else
    27.             If .Tanks > 0 Then
    28.                 .Tanks = .Tanks - (AJeep \ 3)
    29.             Else
    30.                 .Crawlers = .Crawlers - (AJeep \ 10)
    31.             End If
    32.         End If 'Jeep attack order: Jeep, Tank, Crawler
    33.        
    34.         If .Tanks > 0 Then
    35.             .Tanks = .Tanks - (ATank \ 3)
    36.         Else
    37.             If .Jeeps > 0 Then
    38.                 .Jeeps = .Jeeps - (ATank \ 2)
    39.             Else
    40.                 .Crawlers = .Crawlers - (ATank \ 10)
    41.             End If
    42.         End If 'Tank attack order: Tank, Jeep, Crawler
    43.        
    44.         If .Crawlers > 0 Then
    45.             .Crawlers = .Crawlers - (ACrawler \ 10)
    46.         Else
    47.             If .Tanks > 0 Then
    48.                 .Tanks = .Tanks - (ACrawler \ 3)
    49.             Else
    50.                 .Jeeps = .Jeeps - (ACrawler \ 2)
    51.             End If
    52.         End If 'Crawler attack order: Crawler, Tank, Jeep
    53.        
    54.         If .Jeeps < 0 Then .Jeeps = 0
    55.         If .Tanks < 0 Then .Tanks = 0
    56.         If .Crawlers < 0 Then .Crawlers = 0
    57.         If .Jeeps + .Tanks + .Crawlers = 0 Then AttackSuccess = True
    58.     End With
    59.    
    60.     For i = 1 To Sector(DSectorX, DSectorY).Jeeps
    61.         DJeep = DJeep + Int(Rnd * 3)
    62.     Next i
    63.     For i = 1 To Sector(DSectorX, DSectorY).Tanks
    64.         DTank = DTank + Int(Rnd * 8)
    65.     Next i
    66.     For i = 1 To Sector(DSectorX, DSectorY).Crawlers
    67.         DCrawler = DCrawler + Int(Rnd * 9)
    68.     Next i
    69.    
    70.     With Sector(ASectorX, ASectorY)
    71.         If .Jeeps > 0 Then
    72.             .Jeeps = .Jeeps - (DJeep \ 2)
    73.         Else
    74.             If .Tanks > 0 Then
    75.                 .Tanks = .Tanks - (DJeep \ 3)
    76.             Else
    77.                 .Crawlers = .Crawlers - (DJeep \ 10)
    78.             End If
    79.         End If 'Jeep attack order: Jeep, Tank, Crawler
    80.        
    81.         If .Tanks > 0 Then
    82.             .Tanks = .Tanks - (DTank \ 3)
    83.         Else
    84.             If .Jeeps > 0 Then
    85.                 .Jeeps = .Jeeps - (DTank \ 2)
    86.             Else
    87.                 .Crawlers = .Crawlers - (DTank \ 10)
    88.             End If
    89.         End If 'Tank attack order: Tank, Jeep, Crawler
    90.        
    91.         If .Crawlers > 0 Then
    92.             .Crawlers = .Crawlers - (DCrawler \ 10)
    93.         Else
    94.             If .Tanks > 0 Then
    95.                 .Tanks = .Tanks - (DCrawler \ 3)
    96.             Else
    97.                 .Jeeps = .Jeeps - (DCrawler \ 2)
    98.             End If
    99.         End If 'Crawler attack order: Crawler, Tank, Jeep
    100.        
    101.         If .Jeeps < 0 Then .Jeeps = 0
    102.         If .Tanks < 0 Then .Tanks = 0
    103.         If .Crawlers < 0 Then .Crawlers = 0
    104.     If .Jeeps = 0 And .Tanks = 0 And .Crawlers = 0 Then .Owner = 0
    105.     End With
    106.    
    107.     Sector(ASectorX, ASectorY).Attack = True
    108.     Sector(DSectorX, DSectorY).Attack = True
    109.    
    110.     SectorActive = False
    111.     frmBattlefront.lblJeeps.Visible = False
    112.     frmBattlefront.lblTanks.Visible = False
    113.     frmBattlefront.lblCrawlers.Visible = False
    114.  
    115. End Function

  18. #18
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Whats your favourite function?

    VB Code:
    1. On Error Resume Next

  19. #19
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Whats your favourite function?

    Code:
    Process.Terminate

  20. #20
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Whats your favourite function?

    Code:
    Array.Sort

    Oh, the wonders of C#...

  21. #21
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: Whats your favourite function?

    VB Code:
    1. kill


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