473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Extract Weight Value from String

I use this code to capture weight from Avery weigher indicator through serial com

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Read_Click()
  2. 'send the Print command and read the weight value.
  3. NETComm6.Output = "p" & Chr(13) 'send PRINT command to the scale.
  4. Dim Buffer As String 'define Buffer
  5.     Buffer$ = Buffer$ & NETComm6.InputData 'wait for the data come into the serial port
  6.     WtInfo = Buffer
  7. End Sub
  8.  
And i got this
80 00 000S99291235 F80 00 000S99291236 E80 00 000S99291237 D80 00 000S99291238 K80 00 000S9929123

How can I extract the 80 kg to my table field

Thank you
Mar 17 '14 #1
3 1789
jimatqsi
1,271 Expert 1GB
You can break that string into its various parts by using the split() function. If that is a space (it might be some other unprintable character) you can do it like this:
Expand|Select|Wrap|Line Numbers
  1. dim Wtarray as variant
  2. dim Weight as integer  // ?? or whatever is right data type
  3. Wtarray=split(WtInfo)
  4. Weight = Wtarray(0)   // assuming the weight is in the 1st position
  5.  
Jim
Mar 17 '14 #2
Thank you for your reply

I use left(WtInfo,10) instead
Mar 18 '14 #3
NeoPa
32,556 Expert Mod 16PB
There is no "80 kg" within the string. If you specify in your question specifically what it is you are trying to achieve then we can help you. I suspect Jim's answer is a more sensible solution than what you're using but without the details you have as to what it is you actually want it's impossible to say.
Mar 18 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jay Patel | last post by:
Hello, I need to write visual basic.net code to interface with a Mettler Toledo Shipping Scale that interfaces with a PC via USB or a serial port. I have seen example code on how to communicate...
1
by: TdarTdar | last post by:
Hello, I am writing an web base application that needs to read data from a serial port(Postal Scale), I assume i will be using this namespace System.IO.Ports.SerialPort I know in vb it would...
10
by: Ryan Dahl | last post by:
Hi, I'm working on a simple performance-program, where I need to extract information from the 2 newest periods for every performance-indicator - And from there calculate a trend between these...
14
by: Frank Swarbrick | last post by:
A few weeks ago I had posed a question about how one my create a cursor for a query where the predicate condition is dynamic. Meaning that the query might want to have one of several possible...
4
by: GaryMasson | last post by:
Hi. Im pretty new to the mscomm controll and my problem is. Im trying to connecting a weighbridge to Com1 and when i try read the weight on the scale i get a mass of garbage coming trough. ...
0
by: RG | last post by:
I am trying to read from my serial port a 24 bit binary number. I was able to read this number as a HEX but I was getting errors as at times using the vBCrLf indicator. I also can read it as an...
8
by: egrill | last post by:
I have figured out how to extract the serial number of date field into the corresponding number of the week using the DatePart function. The would like to take the 5 and translated it identify the...
7
by: John Wright | last post by:
I have data coming into a serial port that I need to take action on. I have created a delegate to read the data from the port and put it into a text box. Once the data is read, I need to...
7
by: seegoon | last post by:
Hi to all. I have a application that receives data via the serial port. I don't know the number of bytes that are going to be coming in. It could be 10 up to 150. (9600 baud) I have decided to...
3
by: Vinokbhai r k | last post by:
I have developed a software in vb6. In order to protect my software how can I extract CPU serial no. of client's computer in network. I want to extract server's CPU No.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.