Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:36:31+00:00 2026-06-08T18:36:31+00:00

I’d like to know if there is a way to call a timer through

  • 0

I’d like to know if there is a way to call a timer through a function. This function itself is called through an automated timer that is activated when the form loads.

Function callTimer(ByRef var1 As Integer, ByVal var2 As Integer)
    'statements()
    Media.SystemSounds.Beep.Play() 'to ensure that it is called
    Call otherFunction(ByRef var3 As Integer) <-- how do you do this??
    Return var1
End Function

I want to know how this can be done. VB gives me an error when I try this or something like this.

Thanks all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:36:32+00:00Added an answer on June 8, 2026 at 6:36 pm

    What @competent_tech was saying is that you’re defining a function within a function, which is illegal. You want to call the function, not define it. An example of this would be like so:

    Shared _timer As Timer 'this is the timer control
    
    Function callTimer(ByRef var1 As Integer, ByVal var2 As Integer)
        Media.SystemSounds.Beep.Play() 'to ensure that it is called
        Dim testInt As Integer
        testInt = 4
        Call otherFunction(testInt) '<-- this calls otherFunction and passes testInt
        Return var1
    End Function
    
    Function otherFunction(ByRef var3 As Integer)
        StartTimer(var3) ' this will start the timer and set when the timer ticks in ms
                    ' (e.g. 1000ms = 1 second)
    End Function
    
    'this starts the timer and adds a handler. The handler gets called every time 
    'the timer ticks
    Shared Sub StartTimer(ByVal tickTimeInMilliseconds As Integer)
        _timer = New Timer(tickTimeInMilliseconds)
        AddHandler _timer.Elapsed, New ElapsedEventHandler(AddressOf Handler)
        _timer.Enabled = True
    End Sub
    'this is the handler that gets called every time the timer ticks
    Shared Sub Handler(ByVal sender As Object, ByVal e As ElapsedEventArgs)
        ' . . . your custom code here to be called every time the timer tickets
    End Sub
    

    It seems like you might be a little confused with calling a function versus defining a function. Before you can use a function it must be defined, like my example code above.

    Another thing to get a better handle on is the usage of ByRef versus ByVal. ByRef passes a reference to an address in memory. What this means is that any changes to the variable within a function will persist outside of the function. ByVal, however, will not persist outside of the function and the value before being passed to the function will be the same as after the function call. Here is an example of that:

    Sub Main()
        Dim value As Integer = 1
    
        ' The integer value doesn't change here when passed ByVal.
        Example1(value)
        Console.WriteLine(value)
    
        ' The integer value DOES change when passed ByRef.
        Example2(value)
        Console.WriteLine(value)
    End Sub
    
    'any Integer variable passed through here will leave unchanged
    Sub Example1(ByVal test As Integer)
        test = 10
    End Sub
    
    'any Integer variable passed through here will leave with a value of 10
    Sub Example2(ByRef test As Integer)
        test = 10
    End Sub
    

    Result:

    test = 1

    test = 10

    This ByRef/ByVal example can be seen at this link. It’s worth looking more into if you’re still confused.

    EDIT: This edit includes information regarding invoking a timer in VB.NET.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I know there's a lot of other questions out there that deal with this
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I need a function that will clean a strings' special characters. I do NOT
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.