Question need help with functions plzz :D

dxtr

Member
Joined
Oct 12, 2011
Messages
7
Programming Experience
Beginner
im new to vb.net and im making a small program
i have to do something like this :

VB.NET:
Sub decod(ByVal t() As Integer)
'do a test
if( something ) then
decod1(t)
else  decode2(t)
endif
    End Sub

function decod1(byval t() as integer)
dim s as integer
'do things
return s
end function

function decod2(byval t() as integer)
dim m as integer
'do things
return m
end function

then i have a button

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim t(100) As Char
t = "something"
textbox1.text = convert.tostring( decod(t))    
End Sub

the function didn't return anything :( , whats the problem ??
 
Last edited:
So here's a question for you... you define t as a string in your button click, but what object type is your decod function expecting?
 
according to your code, decod is declared as a sub, not a function.
VB.NET:
Sub decod(ByVal t() As Integer)
Which in your button you called
VB.NET:
textbox1.text = convert.tostring( decod(t))

a sub or Subroutine does not return a value. However a Function does, if you called decod1 or decod2 instead you will have a value returned.

As Menthos noted, check the object types that your expecting and that your passing in. Your function and sub are expecting a integer array, and your passing a char array, which cannot be converted.

also you have a syntax error,
VB.NET:
else  decode2(t)
the function decode2 does not exist according to the code you posted, it should be "Else : decod2"
 
Back
Top