Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27196

VS 2010 [RESOLVED] Change string value from a function?

$
0
0
Is it possible to change the value of a string from a function, because I'm having a problem here?
The general idea would be like below, but the string will not change, so is there any way I make that happen?

vb.net Code:
  1. Public Class Form1
  2.  
  3. Dim MyItem1, MyItem2, MyItem3 As Integer
  4.  
  5. Public Function SetItemStats(ByVal CurrentItemSlot As ComboBox, ByVal CurrentItemName As String)
  6.         CurrentItemName = CurrentItemSlot.Text
  7. End Function
  8.  
  9. Private Sub SetItem1Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetItem1Button.Click
  10.         SetItemStats(item1list, MyItem1) ' item1list is the name of my combobox.
  11.         MsgBox(MyItem1) ' Comes out empty here
  12. End Sub
  13.  
  14. End Class

EDIT: Fixed that by changing ByVal into ByRef, I'm such an idiot.

Viewing all articles
Browse latest Browse all 27196

Trending Articles