Results 1 to 9 of 9

Thread: recieve data from weighing machine in vb6

  1. #1

    Thread Starter
    Addicted Member frangine's Avatar
    Join Date
    Jan 2014
    Posts
    152

    recieve data from weighing machine in vb6

    hello guys...i need code that show the previous weight and the current weight then compute the difference between the previous and the current weight

    formula: difference weight = previous weight - current weight

    i can show the form below....

    help me guys, plzzzz...thank you in advance
    Attached Images Attached Images  

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: recieve data from weighing machine in vb6

    Well that is pretty simple, your formula is almost the code you would need just remove the spaces between the words and assign values to the current and previous weights.

    You definitely should be able to write the code yourself in under 10 minutes

  3. #3

    Thread Starter
    Addicted Member frangine's Avatar
    Join Date
    Jan 2014
    Posts
    152

    Re: recieve data from weighing machine in vb6

    hehe...but i have one big problem data comes from a weighing scale through serial port ...how can i show the data from weighing scale to my textbox

  4. #4
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: recieve data from weighing machine in vb6

    Hardly to find an open source for weighing scale communication class or module. I think this kind of software is commercial sensitivity. Sure you can't find the whole cake on VBForums. You may find something on PSC.

  5. #5

    Thread Starter
    Addicted Member frangine's Avatar
    Join Date
    Jan 2014
    Posts
    152

    Re: recieve data from weighing machine in vb6

    i have this code but i have to put this value into my textbox and determine its previous weight , current weight and the difference of this two...

    Code:
    Option Strict Off
    Option Explicit On
    Module InpOut32_Declarations
        Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
        Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
    End Module
    
    Public Class Form1
        Dim intRunning As Integer
        Dim intWeightReadingCount As Integer
        Dim decWeightReadingLast As Decimal
        Dim datetime1 As Date, datetime2 As Date
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'REM Timer1.Enabled = True
            SerialPort1.Open()
            Dim i As Integer
    
            For i = 0 To 10000
                datetime1 = DateTime.Now
                TickTimer2()
            Next
    
        End Sub
    
    
        Private Sub TickTimer2()
            Dim decWeightReading As Decimal, strScaleCommand As String
            Dim strSerialData As String
            Dim strSerialDataNew As String
            Dim strFirstData As String
            Dim cnt As Integer
            Dim diffDate As TimeSpan
    
            decWeightReading = CDec("0.000")
            strScaleCommand = "IP" + vbCrLf
            strFirstData = ""
    
            SerialPort1.WriteLine(strScaleCommand)
            strSerialData = SerialPort1.ReadLine
            strSerialDataNew = ""
            cnt = 0
            Do Until cnt = 10
                SerialPort1.WriteLine(strScaleCommand)
                strSerialDataNew = SerialPort1.ReadLine
                If strSerialDataNew = strSerialData Then
                    cnt = cnt + 1
                Else
                    strSerialData = strSerialDataNew
                    strSerialDataNew = ""
                    cnt = 0
                End If
            Loop
            datetime2 = DateTime.Now
            diffDate = datetime2.Subtract(datetime1)
    
            'MessageBox.Show(diffDate.Milliseconds.ToString + " Weight" + strSerialData)
            'MessageBox.Show(DateDiff(DateInterval.Minute, datetime1, datetime2))
            Console.WriteLine(diffDate.Milliseconds.ToString + " Weight " + strSerialData)
        End Sub
    
      
    End Class

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: recieve data from weighing machine in vb6

    That code is VB.Net. This section of the forum is for VB6 and older so either you have gotten then wrong code or have posted in the wrong section.

    In any case you should not be using a loop like that. The SerialPort class fires an event when data arrives and that is what you should be using

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: recieve data from weighing machine in vb6

    Yeah...yesterday OP said he was using VS 2005...so definitely more than likely he still is....better answers probably available in the .Net forum (although, DM and dilett, I know you can probably answer).

  8. #8

    Thread Starter
    Addicted Member frangine's Avatar
    Join Date
    Jan 2014
    Posts
    152

    Re: recieve data from weighing machine in vb6

    i give you my link..in a right forum..http://www.vbforums.com/showthread.p...port-in-vs2005

  9. #9

    Thread Starter
    Addicted Member frangine's Avatar
    Join Date
    Jan 2014
    Posts
    152

    Re: recieve data from weighing machine in vb6

    can you correct my code...please help me..thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width