Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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
Updated 6-Dec-12 20:56pm
v2

1 solution

use this

VB
If tempp.Length > 12 Then tempp = tempp.Substring(0, 12)


mark as answer if helped.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900