Remove leading 0's in text field
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 216   1
URL.หัวข้อ / URL
Remove leading 0's in text field

ถามไว้ที่
http://www.quicktechusa.com/msgboard/wwwboard.pl?read=17380

คำถามมีดังนี้ครับ



I haven't used Aceess for a while now and I forget how I would do this. If I have a table with a text column in it that has the following entries:
0000123
00-1023
0ABCDEF

How can I check each character, starting at the left and remove it if it's a Zero? I would like the results to be:
123
-1023
ABCDEFG

thanks,
Mike


ผมเลยได้ลองเขียนโค้ดขึ้นมา ดังนี้


Function fLeadingZero(strText As String) As String
Dim I As Integer, strText2 As String
For I = 1 To Len(strText)
If Mid(strText, I, 1) = "0" Then
strText2 = Mid(strText, I + 1)
'Debug.Print strText2 & " " & I
Else
GoTo Tim
End If
Next I

Tim:
fLeadingZero = strText2
End Function


ตัวอย่างจริงอยู่ที่
http://agserver.kku.ac.th/basiceng/LeadingZero.zip
ให้ดูการทำงานในส่วนของ Query ชื่อ query1 ครับ

1 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R06526
   
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0531s