|
แนะนำฟังก์ชั่นในการควบคุมเครื่องพิมพ์ |
|
|
|
|
วันจันทร์ที่ 08 มีนาคม 2010 เวลา 17:36 น. เขียนโดย Pattama
|
|
สวัสดีครับ วันนี้มีเพื่อนๆแนะนำฟังก์ชั่นในการควบคุมเครื่องพิมพ์มานะครับซึ่งก็จะมีหน้าจอที่เป็นภาษาไทยล้วนๆก็ลองโหลดไปดูนะครับ วิธีใช้ก็เพียงแต่copy ฟังก์ชั่นนี้ไปเก็บเอาใว้ที่ library ที่เราต้องการเท่านี้ก็เรียบร้อยแล้วครับ
Print_option.zipl
มีอีก 1 ฟังก์ชั่นเป็นฟังก์ชั่นเกี่ยวกับการคิดส่วนลด เช่น
180 = f_discount(200,20) 160 = f_discount(200,20%) 152 = f_discount(200,20%5%) 122 = f_discount(200,20%5%30) โดยการใช้ฟังก์ชั่นนี้ก็คือกำหนดจำนวนเงินและส่วนลดลงไป เราก็จะได้จำนวนเงินที่หักส่วนลดแล้วออกมา สำหรับสคริปต์ของฟังก์ชั่นและการกำหนดค่าต่างๆก็มีดังนี้ครับ ทำการกำหนด global variable ดังนี้ Integer li_pos,li_len,li_pos2 Dec lde_price ในส่วนของ function declaration ก็กำหนดดังนี้ครับ อ้อ! ตั้งชื่อว่า f_discount นะครับ
| Name |
Type |
Pas by |
| ade_price |
decimal |
value |
| ade_percent |
string |
value |
ส่วนนี้ก็จะเป็นสคริปต์ที่เราต้องเขียนลงไป If Not IsNull(as_percent) and as_percent "0" and as_percent "" then li_len = len(as_percent) li_pos = Pos(as_percent,"%") If li_pos > 0 then lde_price = ade_price - (ade_price * dec(Mid(as_percent,1,li_pos - 1)) / 100) If li_len > li_pos then li_pos2 = Pos(as_percent,"%",li_pos + 1) If li_pos2 > 0 then lde_price = lde_price - (lde_price * dec(Mid(as_percent,li_pos + 1,li_pos2 - li_pos -1))/100) If li_len > li_pos2 then lde_price = lde_price - dec(right(as_percent,li_len - li_pos2)) End if Else lde_price = lde_price - dec(right(as_percent,li_len - li_pos)) End if End if Else lde_price = ade_price - dec(as_percent) End if //ราคาที่ลดแล้ว return lde_price Else //ราคาเดิม return ade_price End if ตัวอย่างการใช้งานก็เช่น Sle_1.text = f_discount(200,20) ก็จะได้ 180 Sle_1.text = f_discount(200,20%) ก็จะได้ 160 สำหรับฟังก์ชั่นทั้งสองนี้ได้รับเอื้อเฟื้อจากคุณ MONTREE PANLERT [
อีเมลนี้จะถูกป้องกันจากสแปมบอท แต่คุณต้องเปิดการใช้งานจาวาสคริปก่อน
]
|
|
แก้ไขล่าสุด ใน วันจันทร์ที่ 08 มีนาคม 2010 เวลา 17:40 น. |