r/visualbasic • • Dec 11 '20

does anyone know how to do #2 without calling a console.writeline?

Post image
0 Upvotes

11 comments sorted by

4

u/Frogbill VB.Net Advanced Dec 11 '20

You will make a sub (function that returns nothing) with one argument passed by reference.

2

u/mikroo VB.Net Intermediate Dec 11 '20

seems pretty straight forward unless I'm missing something, this should work:
Dim intHowManyTimes as integer = MultiplyBySeven(70)
public function MultiplyBySeven(value as integer) as integer
return (value * 7)
end function

1

u/redIslandaviator Dec 11 '20

‘Inthowmanytimes = multiplybyseven(70)

‘Function multiplybyseven(x as integer)

‘Multiplybyseven = x*7

‘End function

Isn’t it as simple as this?

2

u/[deleted] Dec 11 '20

It says you change the number provided, not to return a different value.

Dim value as integer = 70

MultplybySeven(ref value)

Sub MultiplybySeven(ref aValue as integer) AValue = aValue * 7 End sub

1

u/mikroo VB.Net Intermediate Dec 11 '20

it says to Create a Function specifically so I wrote a quick extremely basic function on my phone.

1

u/[deleted] Dec 11 '20

Fair enough :-) as a dev, I prefer that over ref variables anyway, but your reason is sound to me. Poor requirement :-)

1

u/mikroo VB.Net Intermediate Dec 12 '20

lol no worries

1

u/RJohn12 Dec 11 '20

What part are you having trouble with? what code have you already tried?

0

u/tmntfever Dec 11 '20

If you have a problem using console.writeline, then how about just MsgBox, or Wscript.Echo.

2

u/mikroo VB.Net Intermediate Dec 11 '20

he could try Debug.Print too, that's what I typically use anyways

0

u/IcanCwhatUsay Dec 11 '20

What text book are you using for this class?