อยากเปลี่ยน code เป็น โมดูลแทนครับ
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 250   2
URL.หัวข้อ / URL
อยากเปลี่ยน code เป็น โมดูลแทนครับ

สวัสดีครับ รบกวนเพื่อน ๆ และอ.ผมต้องการที่ดัดแปลงcode นี้เป็น โมดูล เพื่อที่นำไปเรียกใช้หลายๆที่  ต้องเขียนอย่างไรครับ  
Private Sub ส่วนรายละเอียด_Print(Cancel As Integer, PrintCount As Integer) 
If Average > 5 Then 
Average.BackColor = RGB(255, 0, 0) 'พื้นสีแดง 
Average.ForeColor = RGB(0, 0, 255) 'ตัวอักษรสีน้ำเงิน 
Else 
Average.BackColor = RGB(255, 255, 255) 'พื้นสีขาว 
Average.ForeColor = RGB(0, 0, 0) 'ตัวอักษรสีดำ 
End If 
End Sub 

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

1 @R01985
เราต้องดูว่าจะให้ตัวไหนเป็นตัวแปรบ้าง จากตัวอย่างที่ให้มา ผมจะให้ ชื่อ control (Average) และ ค่า (5) เป็นตัวแปร ให้เขียนฟังก์ชันนี้ใน Module Public Function SetCon(ctl As Control, MyValue As Integer) If ctl > MyValue Then ctl.BackColor = RGB(255, 0, 0) 'พื้นสีแดง ctl.ForeColor = RGB(0, 0, 255) 'ตัวอักษรสีน้ำเงิน Else ctl.BackColor = RGB(255, 255, 255) 'พื้นสีขาว ctl.ForeColor = RGB(0, 0, 0) 'ตัวอักษรสีดำ End If End Function เมื่อจำไปใช้ ก็ใช้อย่างนี้ครับ Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer) SetCon Me.Price, 5 End Sub
2 @R01989
ขอบคุณครับอ.
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0409s