magh
magh

Reputation: 679

How to get the value from method in Visual Basic 6

The code below returns error after the return statement

Private Sub Command1_Click()
  Dim str As String
  str = display("test")
  MsgBox (str)
End Sub

Public Function display(s As String) As String
  s = "updated"
  Return s
End Function

Any ideas why?

Upvotes: 0

Views: 634

Answers (1)

hgulyan
hgulyan

Reputation: 8239

Change display function. The difference is that in vb6 functions return a value not with return, but with it's name(in this case display), like below.

   Public Function display(s As String) As String 
       s = "updated" 
       display = s 
   End Function

Upvotes: 1

Related Questions