Sub with two variables???

R

Rayo K

I just added a variable to a sub in a module. It used to receive an integer.
Now it receives an integer and a string.

Excel won't let me pass the string to it. I don't know what is going on.
Here is my sub first line:

Public Sub ShiftNewMonth(MachineType As Integer, MachineName As String)
....
End Sub




I call this sub from a worksheet like this:

Private Sub NewMonthButton_Click()
Dim shtName As String
shtName = "Corrugator"
ShiftNewMonth (1 , shtName)
End Sub

Excel wants me to put an equal sign at the end of "ShiftNewMonth (1 ,
shtName)" as if it's a Function.

If I remove the string and say: ShiftNewMonth (1), it lets it go, but then
it doesn't work because the module is expecting a string. ?????
 
T

Trevor Shuttleworth

Try without the brackets:

Private Sub NewMonthButton_Click()
Dim shtName As String
shtName = "Corrugator"
ShiftNewMonth 1, shtName
End Sub

Regards

Trevor
 
A

Andy Pope

Hi,

Either use

Call ShiftNewMonth(1 , shtName)

or

ShiftNewMonth 1 , shtName

Cheers
Andy
 
R

Rayo K

Weird. Am I crazy or does VB .NET not work that way? I seem to remember
always using parentheses.

Oh, and thanks.It works now
 
T

Trevor Shuttleworth

If you want to return a value from your function/sub, you would use
brackets. For example:

sString = ShiftNewMonth (1, shtName)

Regards

Trevor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top