cmdolcet
asked on
Passing Variables
How to I pass the variable that is required to use the Open_G300_COM sub?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendG300DataUp.Click
Open_G300_COM()
End Sub
Public Sub Open_G300_COM(ByVal e As FarPoint.Win.Spread.Editor NotifyEven tArgs)
Dim activeport As String
Dim serialresponse As String
Dim intmaxrows As Integer
Dim Total_Bytes As String = "34"
Dim Int_Rank As Integer = 0
Dim GageID As String
Dim UpdatePoint As String = "TP"
Dim intloop As Integer
Dim GageDescription As String
Dim USL As String
Dim LSL As String
If Me.gridGages.ActiveSheet.C ells(e.Row , GridColumns.GageType).Text = "G-300" Then
activeport = gridGages.ActiveSheet.Acti veCell.Tex t
If serialPort.IsOpen Then
serialPort.Close()
End If
serialPort.BaudRate = "57600"
serialPort.PortName = "COM" & activeport
serialPort.Parity = IO.Ports.Parity.None
serialPort.DataBits = 8
serialPort.StopBits = 1
serialPort.RtsEnable = True
serialPort.Open()
System.Threading.Thread.Sl eep(150)
'Send Setup Mode to Wireless Base Device to Start the Listning
serialPort.Write("<RS")
'Loops through the Grid Row and sends each Point Parameter back up to the
For intloop = 0 To gridGages.ActiveSheet.RowC ount - 1
GageID = gridGages.ActiveSheet.Cell s(intloop, 1).Text
GageDescription = gridGages.ActiveSheet.Cell s(intloop, 0).Text
If GageDescription.Length > 16 Then
Dim AddSpace As Integer = 0
AddSpace = 16 - GageDescription.Length
ElseIf GageDescription.Length < 16 Then
GageDescription = GageDescription.PadRight(1 6, " ")
End If
USL = gridGages.ActiveSheet.Cell s(intloop, 10).Text
LSL = gridGages.ActiveSheet.Cell s(intloop, 11).Text
If USL.Contains(".") Then
USL = USL.Replace(".", "").PadLeft(4, "0")
End If
If LSL.Contains(".") Then
LSL = LSL.Replace(".", "").PadLeft(4, "0")
End If
System.Threading.Thread.Sl eep(200)
serialPort.Write("<@:L" & GageID & Total_Bytes & "<" & UpdatePoint & "," & "0" & Int_Rank & "," & GageDescription & "," & USL & "," & LSL & ">")
System.Threading.Thread.Sl eep(150)
serialresponse = serialPort.ReadExisting
Int_Rank = +1
Next
End If
serialPort.Write("<RN")
serialPort.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendG300DataUp.Click
Open_G300_COM()
End Sub
Public Sub Open_G300_COM(ByVal e As FarPoint.Win.Spread.Editor
Dim activeport As String
Dim serialresponse As String
Dim intmaxrows As Integer
Dim Total_Bytes As String = "34"
Dim Int_Rank As Integer = 0
Dim GageID As String
Dim UpdatePoint As String = "TP"
Dim intloop As Integer
Dim GageDescription As String
Dim USL As String
Dim LSL As String
If Me.gridGages.ActiveSheet.C
activeport = gridGages.ActiveSheet.Acti
If serialPort.IsOpen Then
serialPort.Close()
End If
serialPort.BaudRate = "57600"
serialPort.PortName = "COM" & activeport
serialPort.Parity = IO.Ports.Parity.None
serialPort.DataBits = 8
serialPort.StopBits = 1
serialPort.RtsEnable = True
serialPort.Open()
System.Threading.Thread.Sl
'Send Setup Mode to Wireless Base Device to Start the Listning
serialPort.Write("<RS")
'Loops through the Grid Row and sends each Point Parameter back up to the
For intloop = 0 To gridGages.ActiveSheet.RowC
GageID = gridGages.ActiveSheet.Cell
GageDescription = gridGages.ActiveSheet.Cell
If GageDescription.Length > 16 Then
Dim AddSpace As Integer = 0
AddSpace = 16 - GageDescription.Length
ElseIf GageDescription.Length < 16 Then
GageDescription = GageDescription.PadRight(1
End If
USL = gridGages.ActiveSheet.Cell
LSL = gridGages.ActiveSheet.Cell
If USL.Contains(".") Then
USL = USL.Replace(".", "").PadLeft(4, "0")
End If
If LSL.Contains(".") Then
LSL = LSL.Replace(".", "").PadLeft(4, "0")
End If
System.Threading.Thread.Sl
serialPort.Write("<@:L" & GageID & Total_Bytes & "<" & UpdatePoint & "," & "0" & Int_Rank & "," & GageDescription & "," & USL & "," & LSL & ">")
System.Threading.Thread.Sl
serialresponse = serialPort.ReadExisting
Int_Rank = +1
Next
End If
serialPort.Write("<RN")
serialPort.Close()
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I do get an error after I pass nothing. I get an Null Reference Error. I have attached the actual screen
Thanks
Thanks
>I have attached the actual screen
No you have not.
Which line generates the error as I don't see e being used anywhere.
No you have not.
Which line generates the error as I don't see e being used anywhere.
ASKER
Code Cruiser, I am going to try this again please see attached
Also it happens on this line:
If Me.gridGages.ActiveSheet.C ells(e.Row , GridColumns.GageType).Text = "G-300" Then
Error-1.png
Also it happens on this line:
If Me.gridGages.ActiveSheet.C
Error-1.png
Do you get an error when pass it as Open_G300_COM()?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes that is my question how can I pass this by ref or by val in the code above?
Check out this link:
http://www.gcpowertools.com/help/spreadnet6/WF/FarPoint.Win.Spread~FarPoint.Win.Spread.FpSpread~ButtonClicked_EV.html
I think that it should be:
Public Sub Open_G300_COM(ByVal sender as object, ByVal e As FarPoint.Win.Spread.Editor NotifyEven tArgs)
http://www.gcpowertools.com/help/spreadnet6/WF/FarPoint.Win.Spread~FarPoint.Win.Spread.FpSpread~ButtonClicked_EV.html
I think that it should be:
Public Sub Open_G300_COM(ByVal sender as object, ByVal e As FarPoint.Win.Spread.Editor
ASKER
Ok but what is passed into the:
Open_G300_COM()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendG300DataUp.Click
Open_G300_COM()
End Sub
Open_G300_COM()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendG300DataUp.Click
Open_G300_COM()
End Sub
Add 'Handles' to the method for the data and remove the Button1_Click event.
Public Sub Open_G300_COM(ByVal sender as object, ByVal e As FarPoint.Win.Spread.Editor NotifyEven tArgs) Handles btnSendG300DataUp.Click
Public Sub Open_G300_COM(ByVal sender as object, ByVal e As FarPoint.Win.Spread.Editor
ASKER
OK Sorry but you lost me on that one. When I add the handles onto the following:
Public Sub Open_G300_COM(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.Editor NotifyEven tArgs) Handles btnSendG300DataUp.Click
on the click property it says it cannot handle event Public Click(sender as object, e as system.EventArgs because they do not have the same signature.
Public Sub Open_G300_COM(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.Editor
on the click property it says it cannot handle event Public Click(sender as object, e as system.EventArgs because they do not have the same signature.
Sorry, I think that it should have been ButtonClicked and not Clicked
Public Sub Open_G300_COM(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.Editor NotifyEven tArgs) Handles btnSendG300DataUp.ButtonCl icked
http://www.gcpowertools.com/help/spreadnet6/WF/FarPoint.Win.Spread~FarPoint.Win.Spread.FpSpread~ButtonClicked_EV.html
Public Sub Open_G300_COM(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.Editor
http://www.gcpowertools.com/help/spreadnet6/WF/FarPoint.Win.Spread~FarPoint.Win.Spread.FpSpread~ButtonClicked_EV.html
@imiller1979
He is trying to manually call that method.
@cmdolcet
I have not used that component so don't have much information about it. You would have to do some digging.
He is trying to manually call that method.
@cmdolcet
I have not used that component so don't have much information about it. You would have to do some digging.
I am like @codeCruiser and haven't used this component.
If you can't assign the method to the ButtonClick event as I described above, you may be able to do something like:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim btnSender as button = DirectCast(sender, button)
Dim a as New FarPoint.Win.Spread.Editor NotifyEven tArgs
Open_G300_COM(btnSender, a))
End Sub
Public Sub Open_G300_COM(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.Editor NotifyEven tArgs)
If you can't assign the method to the ButtonClick event as I described above, you may be able to do something like:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim btnSender as button = DirectCast(sender, button)
Dim a as New FarPoint.Win.Spread.Editor
Open_G300_COM(btnSender, a))
End Sub
Public Sub Open_G300_COM(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.Editor
ASKER
OK here's what I did to get it to work:
I passed the FarPoint.Win.Spread.FpSpre ad by Ref) .
Public Sub Open_G300_COM(ByRef gridGages As FarPoint.Win.Spread.FpSpre ad)
Then in my button click event I did the following:
Private Sub btnSendG300DataUp_Click(By Val sender As System.Object, ByVal e As System.EventArgs) Handles btnSendG300DataUp.Click
Open_G300_COM(Me.gridGages )
End Sub
I think that both of you help me realize my issues so I will be splitting the points.
Thanks
I passed the FarPoint.Win.Spread.FpSpre
Public Sub Open_G300_COM(ByRef gridGages As FarPoint.Win.Spread.FpSpre
Then in my button click event I did the following:
Private Sub btnSendG300DataUp_Click(By
Open_G300_COM(Me.gridGages
End Sub
I think that both of you help me realize my issues so I will be splitting the points.
Thanks
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for cmdolcet's comment #a38423197
for the following reason:
After look over other code examples I need to pass it byRef and then I could use the control
Accepted answer: 0 points for cmdolcet's comment #a38423197
for the following reason:
After look over other code examples I need to pass it byRef and then I could use the control
YOu are not splitting the points are you?
Open_G300_COM(Nothing)