Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to call a function

how to call this function, or use its out ppput in other operations.
it converts a binary number to its decimal form, but i do not know how to use the decimal form ( this functions out put). "paramter" suposed to stands for the text box i will use later on when i call it.

Public Function binarytodecimal(parameter As String) As String
Dim position As Integer
Dim decimalnumber As Integer
Dim power As Integer
Dim number As Integer
Dim counter As Integer
Dim input1 As String

position = 1
decimalnumber = 0
power = 0
number = 0
counter = 1
While counter <= Len(parameter)
binary = Mid$(parameter, position, 1)
number = binary * (2 ^ power) + decimalnumber
power = power + 1
position = position + 1
decimalnumber = number
counter = counter + 1
Wend
input1 = decimalnumber
End Function
the required variable to be used later is input1, but i dont know how to deal with it
thank you in advance

Comments

  • slickDevslickDev Member Posts: 9
    : how to call this function, or use its out ppput in other operations.
    : it converts a binary number to its decimal form, but i do not know how to use the decimal form ( this functions out put). "paramter" suposed to stands for the text box i will use later on when i call it.
    :
    : Public Function binarytodecimal(parameter As String) As String
    : Dim position As Integer
    : Dim decimalnumber As Integer
    : Dim power As Integer
    : Dim number As Integer
    : Dim counter As Integer
    : Dim input1 As String
    :
    : position = 1
    : decimalnumber = 0
    : power = 0
    : number = 0
    : counter = 1
    : While counter <= Len(parameter)
    : binary = Mid$(parameter, position, 1)
    : number = binary * (2 ^ power) + decimalnumber
    : power = power + 1
    : position = position + 1
    : decimalnumber = number
    : counter = counter + 1
    : Wend
    : input1 = decimalnumber
    : End Function
    : the required variable to be used later is input1, but i dont know how to deal with it
    : thank you in advance
    :
    Hi
    1.Before 'End Function' and After 'input1=decimalnumber' you must add this line of code: binarytodecimal=input1
    The functions returns the results. 2.
    If you want the variable input1 to return a result you must declare the input1 variable into a module as Public. expl.:In the declaration setion of a module type This:
    Public input1 as string
    then you can use the input1 in your function and anywhere you want in your code. But if you use input1 in a public function is unusable because you can get the return value directly from the function.
    I hope this help you understading how the functions works.


Sign In or Register to comment.