swapping two numbers using a function in vb 6)

how to swap two numbers using a function in vb 6

Page 1 of 1

1 Replies - 12126 Views - Last Post: 25 September 2010 - 04:18 AM Rate Topic: -----

#1 rohitkuk  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 9
  • Joined: 30-December 09

swapping two numbers using a function in vb 6)

Posted 25 September 2010 - 12:04 AM

how to swap two numbers by using a function in vb 6
command1 _ click()
dim a,b as integer
a=10
b=20
swap a,b(error here type mis match)
text1.text=a
text2.text=b
end sub
Public Function swap(byref x As Integer, ByRef y As Integer)
Dim temp As Integer
temp = x
x = y
y = temp
End Function
Is This A Good Question/Topic? 0
  • +

Replies To: swapping two numbers using a function in vb 6)

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: swapping two numbers using a function in vb 6)

Posted 25 September 2010 - 04:18 AM

change declaration:
Dim a As Integer, b As Integer



the way you declare your variables. variable a is of type variant (if i remember correct) and b is of type integer. so on your function you try to pass variant type to type integer by reference and that is why error show up.

good luck :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1