Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - olem

Pages: [1]
1
Support Questions / Re: Edit driver between child forms
« on: September 30, 2018, 06:52:23 AM »
Tank you for all the suggestions. Never got this too work with this solution. I think it is a permission issue between two different child forms from the same parent.
My solution is to just call the setup form from the form where the driver is located. In this way the form with the driver is the parent form for the setup form.

Button.click() on the form where the driver is located
        ' Ã…pne en dialogboks med innstillingene
        If oppsettForm.ShowDialog <> DialogResult.OK Then
            MessageBox.Show("Ingenting ble lagert!", "Innstillinger", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        Else
            MessageBox.Show("De nye innstillingene ble lagert!", "Innstillinger", MessageBoxButtons.OK, MessageBoxIcon.Information)

            ' Endre hva Parity vises som
            Dim Parity As String = 0
            Select Case oppsettForm.cbParity.Text
                Case "None"
                    Parity = 0
                Case "Odd"
                    Parity = 1
                Case "Even"
                    Parity = 2
                Case "Mark"
                    Parity = 3
                Case "Space"
                    Parity = 4
            End Select

            ' Endre hva StopBits vises som
            Dim StopBits As String = 0
            Select Case oppsettForm.cbStopBits.Text
                Case "None"
                    StopBits = 0
                Case "One"
                    StopBits = 1
                Case "Two"
                    StopBits = 2
                Case "OnePointFife"
                    StopBits = 3
            End Select

            Me.ModbusRTUCom1.BaudRate = oppsettForm.tbBaud.Text
            Me.ModbusRTUCom1.PortName = oppsettForm.cbComport.Text
            Me.ModbusRTUCom1.DataBits = oppsettForm.tbDataBits.Text
            Me.ModbusRTUCom1.Parity = Parity
            Me.ModbusRTUCom1.PollRateOverride = oppsettForm.tbPollrate.Text
            Me.ModbusRTUCom1.StationAddress = oppsettForm.tbAddresse.Text
            Me.ModbusRTUCom1.StopBits = StopBits

        End If

2
Support Questions / Re: Edit driver between child forms
« on: September 29, 2018, 02:07:24 AM »
Did not get this to work.

If i make a button inside the form where the driver is located. Then I can change the driver, and the label will show the new value with the same code as in the funcion.

    Private Sub BasicButton1_Click(sender As Object, e As EventArgs) Handles BasicButton1.Click
        ModbusRTUCom1.PortName = "COM4"
    End Sub


Sendt the code to your inbox if you would like to take a look.

3
Support Questions / Edit driver between child forms
« on: September 28, 2018, 12:04:01 PM »
Hello, I am having some trouble changing the comport from a child form in a mdi.

"mainform" - mdiparent
|_"oppsettForm"  - Setup
|_"husForm"  - the page that is displaying the components. (modbus rtu driver is on this form)

I have made a function on "husForm" that when called updates the settings for the driver.

Public Sub ReceiveValue(ByVal BaudRate As String, ByVal cbComport As String, ByVal tbBaud As String, ByVal tbDataBits As String, ByVal Parity As String, ByVal tbPollrate As
                                     String, ByVal tbAddresse As String, ByVal StopBits As String)
        Me.ModbusRTUCom1.BaudRate = BaudRate
        Me.ModbusRTUCom1.PortName = cbComport
        Me.ModbusRTUCom1.BaudRate = tbBaud
        Me.ModbusRTUCom1.DataBits = tbDataBits
        Me.ModbusRTUCom1.Parity = Parity
        Me.ModbusRTUCom1.PollRateOverride = tbPollrate
        Me.ModbusRTUCom1.StationAddress = tbAddresse
        Me.ModbusRTUCom1.StopBits = StopBits

        ' MsgBox(cbComport)    '''''This is just to see if i can display the value sendt to the function. (It does show the value i pass to the function)
    End Sub


On the setup page i call the function.

husForm.ReceiveValue(tbBaud.Text, cbComport.Text, tbBaud.Text, tbDataBits.Text, Parity, tbPollrate.Text, tbAddresse.Text, StopBits)


However it does not update the comport. It updates the baud rate and other stuff.

I tried to make a button that gets the values from  ModbusRTUCom1.(baud,parity and so on), but the text does not update when i update the driver. It only list up the default values that i set in Visual Studio.

Tried to set  modifiers ModbusRTUCom1 to Public, still no luck.


Any help would be appreciated. :)

Pages: [1]