# swapping two numbers using a function in vb 6)

Page 1 of 1

## 1 Replies - 36526 Views - Last Post: 25 September 2010 - 04:18 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=191950&amp;s=3172a6547683bd140726c68a109ee9a4&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 rohitkuk

Reputation: -3
• 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_

• Like a lollipop

Reputation: 469
• Posts: 4,281
• 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