Click here to Skip to main content
16,010,673 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble13-Mar-08 11:20
Cory Kimble13-Mar-08 11:20 
GeneralRe: Network communication from a mobile device to desktop Pin
nlarson1113-Mar-08 11:21
nlarson1113-Mar-08 11:21 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble14-Mar-08 3:40
Cory Kimble14-Mar-08 3:40 
GeneralPage Break for report Pin
Chris Dykes13-Mar-08 9:52
Chris Dykes13-Mar-08 9:52 
GeneralRe: Page Break for report Pin
Dave Kreskowiak14-Mar-08 8:15
mveDave Kreskowiak14-Mar-08 8:15 
GeneralRe: Page Break for report Pin
Chris Dykes14-Mar-08 8:20
Chris Dykes14-Mar-08 8:20 
GeneralRe: Page Break for report Pin
Dave Kreskowiak14-Mar-08 9:50
mveDave Kreskowiak14-Mar-08 9:50 
GeneralConfused about ByVal Pin
Kevin Brydon13-Mar-08 6:19
Kevin Brydon13-Mar-08 6:19 
Hi,

I'm a little confused about sending a variable into a function ByVal. I've always understood it that if you send it by value the program will make a copy of the variable and anything you do to that variable inside the function will not affect the original one. Thing is my code seems to contradict this. (i hate it when people post loads of code so i've simplified it)
class SomeClass

   ' a ticket has a property .Message which is a Mymailer.Message
   private ticket as MyMailer.Ticket

   private function DoSomething(ByVal message as MyMailer.Message) as Mymailer.Message
      message.Subject = "Test subject"
      message.Body = "This is a test message"
      return message
   end function

   private sub SomeSubroutine()
      dim newMessage as MyMailer.Message = DoMailMerge(ticket.Message)
   end sub

end class


for some reason when i call SomeSubroutine() the message contained in the variable 'ticket' is changed, even though i passed it by value.

can anyone see why the variable ticket would be affected?

it works if the DoSomething function is:

private function DoSomething(ByVal message as MyMailer.Message) as Mymailer.Message
   dim subject as string = "TestSubject"
   dim body as string = "This is a test message"

   dim newmessage as new MyMailer.Message
   newmessage.Subject = subject
   newmessage.Body = body
   return newmessage
end function


kevin
GeneralRe: Confused about ByVal Pin
Christian Graus13-Mar-08 9:57
protectorChristian Graus13-Mar-08 9:57 
GeneralRe: Confused about ByVal Pin
MikeMarq13-Mar-08 10:40
MikeMarq13-Mar-08 10:40 
GeneralRe: Confused about ByVal Pin
Kevin Brydon13-Mar-08 23:14
Kevin Brydon13-Mar-08 23:14 
QuestionOpening database connection Pin
johnjsm13-Mar-08 5:24
johnjsm13-Mar-08 5:24 
GeneralRe: Opening database connection Pin
Christian Graus13-Mar-08 9:58
protectorChristian Graus13-Mar-08 9:58 
QuestionBackground Workers with Asynch TCP Connections [modified] Pin
Chinners13-Mar-08 5:19
Chinners13-Mar-08 5:19 
GeneralVISTA AREO in VB.NET Pin
vbbeg13-Mar-08 4:31
vbbeg13-Mar-08 4:31 
GeneralRe: VISTA AREO in VB.NET Pin
Colin Angus Mackay13-Mar-08 5:06
Colin Angus Mackay13-Mar-08 5:06 
GeneralRe: VISTA AREO in VB.NET Pin
vbbeg13-Mar-08 20:37
vbbeg13-Mar-08 20:37 
GeneralRe: VISTA AREO in VB.NET Pin
Colin Angus Mackay13-Mar-08 23:06
Colin Angus Mackay13-Mar-08 23:06 
Questionrun time error please help Pin
asha_s13-Mar-08 4:06
asha_s13-Mar-08 4:06 
GeneralRe: run time error please help Pin
Chinners13-Mar-08 6:11
Chinners13-Mar-08 6:11 
GeneralRe: run time error please help Pin
asha_s13-Mar-08 10:02
asha_s13-Mar-08 10:02 
GeneralSpeed Up OleDbDataAdapter.Update() Pin
A Wong13-Mar-08 3:54
A Wong13-Mar-08 3:54 
GeneralRe: Speed Up OleDbDataAdapter.Update() Pin
Dave Kreskowiak14-Mar-08 8:20
mveDave Kreskowiak14-Mar-08 8:20 
GeneralRe: Speed Up OleDbDataAdapter.Update() Pin
A Wong14-Mar-08 8:26
A Wong14-Mar-08 8:26 
GeneralRe: Speed Up OleDbDataAdapter.Update() Pin
Dave Kreskowiak14-Mar-08 10:04
mveDave Kreskowiak14-Mar-08 10:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.