Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Private Sub SMSPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles comPort.DataReceived
 
Dim str As String = ""
Dim temp As String = ""
 
objCon.GetConnectionString()
If e.EventType = SerialData.Chars Then
 
SMSPort.DtrEnable = True
System.Threading.Thread.Sleep(100)
tempp = SMSPort.ReadExisting().Replace(">", "").Trim()
 
//' iwant to add here split function to split more than 12 charcters into only 12 character then give entry into database..
 
'For i As Integer = 1 To tempp.Length Step 12
' Debug.Write(Mid(tempp, i, 12))
 
If tempp <> "" Then
objCon.GetConnectionString()
objCon.GetConnection("Insert into tblAttended(Id,Status,Date,Time)values('" + tempp.ToString() + "','In','" + System.DateTime.Today.ToShortDateString() + "','" + DateTime.Now.ToShortTimeString() + "')")
 
ListView1.Items.Add(tempp)
txtUniqueNumber.Text = tempp.Trim()
ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
End If
'Next i
 
Control.CheckForIllegalCrossThreadCalls = False
  
End Sub
Posted 6-Dec-12 20:43pm
Edited 6-Dec-12 20:56pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

use this
 
    If tempp.Length > 12 Then tempp = tempp.Substring(0, 12)
 
mark as answer if helped.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100