help plz

sandy70

Registered User.
Local time
Today, 08:43
Joined
Apr 16, 2008
Messages
41
hi

can someone help me to fix this problem

i got this sms : 1001,2010,458,456=10,895,893,5677=150,....

any way how to change that into
1001=10,2010=10,458=10,456=10,895=150,893=150,5677=150,...

i working in TOTO project ow..:D

somebody help plz
 
You'll have to give more context as to what it is that you're trying to achieve.

Why does 1001, 2010 etc equate to 10 but 895, 893 and 5677 equate to 150?

What's Toto apart from an 80's AOR band or a small dog?
 
You'll have to give more context as to what it is that you're trying to achieve.

Why does 1001, 2010 etc equate to 10 but 895, 893 and 5677 equate to 150?

What's Toto apart from an 80's AOR band or a small dog?

This is apart of Singapore Pools ( 4D )

Some of my friends are selling that kind of toto
For ex. Someone want to buy some number 1001 for $ 10 , 2010 for $ 10 , 895 for $ 15, 893 for $ 15 , 5677 for $ 15....
Usually i told them to sent message to my SMS Gateway by using this format : 1001x10,2010x10,895x15,893x15,5677x15
So i can manage that sms into my table
Number Price
1000 10
2010 10
895 . 15
893 ..15
5677 15
Everything works fine using that sms format
But now some client does not want to send that kind of sms
they sent me this kind of sms 1010,2010,x10,895,893,5677,x15

How can i transform those sms into my table ??
 
This is similar to a problem I had. I have adapted my solution to fit your data (as I see it). One problem you face is the likely differences of syntax your users will employ - in your own examples, you use two fifferent variations.
I have built the following code behind a command button named cmd1 and I have inserted four test case strings which you can select by commenting out the ones you don't want on successive test runs. You may need to adjust my logic to suit your specific cases, but the principle should work OK.
I have pu comments in to help, but if anything's not clear, please let me know.
Code:
Private Sub cmd1_Click()
Dim strArray1() As String, strArray2() As String
Dim strMultiplier As String, strText As String, strOut As String, strDelimiter As String * 1
Dim varDelimiters As Variant
Dim i As Integer, j As Integer, k As Integer, p As Integer
Rem retrieve text from wherever it's held from the SMS
Rem for this test, use literal strings to represent possible scenarios
strText = "1001,2010,458,456=10,895,893,5677=150" ' test case 1
'strText = "1001,2010,458,456=10,895,893,5677=150" ' test case 2
'strText = "1010 2010 x10 895 893 5677 x15"        ' test case 3
'strText = "1001 2010 458 456=10 895 893 5677=150" ' test case 4
Rem initialise array with all possible delimiters
varDelimiters = Array(",", " ")
For i = 0 To UBound(varDelimiters)
  strArray1 = Split(strText, varDelimiters(i))
  Rem check if array has single element - indicates delimiter not present in input
  If UBound(strArray1) > 1 Then Exit For
Next
ReDim strArray2(0)
For i = 0 To UBound(strArray1)
  p = InStr(1, strArray1(i), "=")               ' 1st possible multiplier delimiter
  If p = 0 Then p = InStr(1, strArray1(i), "x") ' 2nd possible multiplier delimiter
  Rem repeat the line above for each variant of multiplier delimiter (e.g. [EMAIL="'@'"]'@'[/EMAIL])
  If Not p = 0 Then
    strMultiplier = Right(strArray1(i), Len(strArray1(i)) - p)
    Rem check whether current element has a term preceding the multiplier
    If p > 1 Then
      Rem term present; remove the multiplier
      strArray1(i) = Left(strArray1(i), p - 1)
      k = UBound(strArray2)
      ReDim Preserve strArray2(i)
    Else
      Rem term not present; clear the element
      strArray1(i) = vbNullString
      k = UBound(strArray2)
      ReDim Preserve strArray2(i - 1)
    End If
    Rem step through the multiplier array to find empty slot to populate
    For j = k To UBound(strArray2)
      If strArray2(j) = vbNullString Then
        strArray2(j) = strMultiplier
      End If
    Next
  End If
Next
Rem reconstitute the two arrays into a single string
strOut = vbNullString
For i = 0 To UBound(strArray1)
  If strArray1(i) <> vbNullString Then
    If strOut <> vbNullString Then strOut = strOut & ","
    strOut = strOut & strArray1(i) & "=" & strArray2(i)
  End If
Next
MsgBox "Input string:" & vbCr & strText & vbCr & vbCr & "Output string:" & vbCr & strOut, vbInformation, "Test Results"
End Sub
Good luck!
 
This is similar to a problem I had. I have adapted my solution to fit your data (as I see it). One problem you face is the likely differences of syntax your users will employ - in your own examples, you use two fifferent variations.
I have built the following code behind a command button named cmd1 and I have inserted four test case strings which you can select by commenting out the ones you don't want on successive test runs. You may need to adjust my logic to suit your specific cases, but the principle should work OK.
I have pu comments in to help, but if anything's not clear, please let me know.
Code:
Private Sub cmd1_Click()
Dim strArray1() As String, strArray2() As String
Dim strMultiplier As String, strText As String, strOut As String, strDelimiter As String * 1
Dim varDelimiters As Variant
Dim i As Integer, j As Integer, k As Integer, p As Integer
Rem retrieve text from wherever it's held from the SMS
Rem for this test, use literal strings to represent possible scenarios
strText = "1001,2010,458,456=10,895,893,5677=150" ' test case 1
'strText = "1001,2010,458,456=10,895,893,5677=150" ' test case 2
'strText = "1010 2010 x10 895 893 5677 x15"        ' test case 3
'strText = "1001 2010 458 456=10 895 893 5677=150" ' test case 4
Rem initialise array with all possible delimiters
varDelimiters = Array(",", " ")
For i = 0 To UBound(varDelimiters)
  strArray1 = Split(strText, varDelimiters(i))
  Rem check if array has single element - indicates delimiter not present in input
  If UBound(strArray1) > 1 Then Exit For
Next
ReDim strArray2(0)
For i = 0 To UBound(strArray1)
  p = InStr(1, strArray1(i), "=")               ' 1st possible multiplier delimiter
  If p = 0 Then p = InStr(1, strArray1(i), "x") ' 2nd possible multiplier delimiter
  Rem repeat the line above for each variant of multiplier delimiter (e.g. '@')
  If Not p = 0 Then
    strMultiplier = Right(strArray1(i), Len(strArray1(i)) - p)
    Rem check whether current element has a term preceding the multiplier
    If p > 1 Then
      Rem term present; remove the multiplier
      strArray1(i) = Left(strArray1(i), p - 1)
      k = UBound(strArray2)
      ReDim Preserve strArray2(i)
    Else
      Rem term not present; clear the element
      strArray1(i) = vbNullString
      k = UBound(strArray2)
      ReDim Preserve strArray2(i - 1)
    End If
    Rem step through the multiplier array to find empty slot to populate
    For j = k To UBound(strArray2)
      If strArray2(j) = vbNullString Then
        strArray2(j) = strMultiplier
      End If
    Next
  End If
Next
Rem reconstitute the two arrays into a single string
strOut = vbNullString
For i = 0 To UBound(strArray1)
  If strArray1(i) <> vbNullString Then
    If strOut <> vbNullString Then strOut = strOut & ","
    strOut = strOut & strArray1(i) & "=" & strArray2(i)
  End If
Next
MsgBox "Input string:" & vbCr & strText & vbCr & vbCr & "Output string:" & vbCr & strOut, vbInformation, "Test Results"
End Sub
Good luck!
its works perfectly...:D >>> Tab 03

but how can i put those results into my table ??

I have two table , one for SMS_in >>> Tab 01

another one for result >> Tab 02
 

Attachments

  • Tab 03.JPG
    Tab 03.JPG
    32.1 KB · Views: 101
  • Tab 01.JPG
    Tab 01.JPG
    55.1 KB · Views: 105
  • Tab 02.JPG
    Tab 02.JPG
    26.8 KB · Views: 109
The raw data for SMS_IN is presumably the SMS text as received? You could use CurrentDb.Execute "INSERT INTO tab_01 (sms_txt) VALUES (" & strText & ");" [not sure of the syntax here, as I'm using my iPad now, so can't test].
Next, you can use a loop to insert the values from strArray1 [in the test code] to plug the individual Numbers and strArray2 to the Price into your Temp table (along with the other values you have for other fields).
If no-one else posts a better solution, I'll give you more specifics tomorrow morning UK time.
 
The raw data for SMS_IN is presumably the SMS text as received? You could use CurrentDb.Execute "INSERT INTO tab_01 (sms_txt) VALUES (" & strText & ");" [not sure of the syntax here, as I'm using my iPad now, so can't test].
Next, you can use a loop to insert the values from strArray1 [in the test code] to plug the individual Numbers and strArray2 to the Price into your Temp table (along with the other values you have for other fields).
If no-one else posts a better solution, I'll give you more specifics tomorrow morning UK time.
The sms_text in SMS_in is from my gateway SMS
 
The sms_text in SMS_in is from my gateway SMS
Does that mean table tab_01 with field sms_text is your starting point? If so, the problem you have is *just* to get the deconstructed text into your Temp table, linked to tab_01?
The question I have now I've looked more closely at your two tables is how they are linked? To me, the Temp table should have a pointer back to the SMS_IN tble, but it's not there. What am I missing?
 
i try this code
CurrentDb.Execute "INSERT INTO Temp (NumND,Price) VALUES ('" & strArray1(i) & "','" & strArray2(i) & "')"

Its works ( Tab 05 ) but stil i got nothing in Date , CustID and Sender Field

Do i miss something ??
 

Attachments

  • Tab 05.JPG
    Tab 05.JPG
    27.8 KB · Views: 102
It looks like you have most of the problem solved. To populate the remaining fields, you need to include them in the INSERT statement, using values you have stored elsewhere (those you list are in the SMS_IN table, by the look of it.
It may be better to have a Customer table which holds the Id (like AA001 or whatever), along with the mobile number - that way you don't have to repeat it in every table (and you have less chance of errors creeping in). Also, your temp table could point back to the SMS_IN record, so all you need in the Temp table is the deconstructed unit/price items. This thought then raises the question about storing the deconstructed items at all - you have the logic to do this from the input message directly, whenever needed. This depends very much on what you want to do with these elements.
HTH
 
Does that mean table tab_01 with field sms_text is your starting point? If so, the problem you have is *just* to get the deconstructed text into your Temp table, linked to tab_01?
The question I have now I've looked more closely at your two tables is how they are linked? To me, the Temp table should have a pointer back to the SMS_IN tble, but it's not there. What am I missing?
SMS_IN is linked to my gateway database
Temp is the table where i place data from SMS_in after i "extract" them
so , there is no link between them

After some one send SMS to my server ( eg. 1020.2010x10 ) , access wil read the sms and split them into 1020x10,2010x10 and insert this data into my temp table

From Tab 01 then the data become Tab 05
 
It looks like you have most of the problem solved. To populate the remaining fields, you need to include them in the INSERT statement, using values you have stored elsewhere (those you list are in the SMS_IN table, by the look of it.
It may be better to have a Customer table which holds the Id (like AA001 or whatever), along with the mobile number - that way you don't have to repeat it in every table (and you have less chance of errors creeping in). Also, your temp table could point back to the SMS_IN record, so all you need in the Temp table is the deconstructed unit/price items. This thought then raises the question about storing the deconstructed items at all - you have the logic to do this from the input message directly, whenever needed. This depends very much on what you want to do with these elements.
HTH

1 more thing
my data source is from SMS_in table
how can i set them to read it from my source data ??
 

Users who are viewing this thread

Back
Top Bottom