กรุณาเลือก แสดงผลรูปแบบโทรศัพท์มือถือ | แสดงผลรูแบบคอมพิวเตอร์

Dekcom Board • The Ultimate Knowledge Share

 ลืมรหัสผ่าน
 ลงทะเบียน
ค้นหา
ดู: 607|ตอบ: 0

ตัวอย่างโปรแกรมคำนวณหาส่วนลด VCD โดยการสร้างฟังก์ชั่น [คัดลอกลิงก์]

Rank: 9Rank: 9Rank: 9

Money
51
จิตพิศัย
64
สมัครสมาชิกเมื่อ
2009-12-20
เครดิต
64
โพสต์
136
noom โพสต์เมื่อ 2010-1-19 20:08:50 |แสดงโพสต์ทั้งหมด
  1. Module VCD
  2.     Function vcd(ByVal qty As Integer, ByVal member As String) As Decimal
  3.         Dim total As Decimal = 0
  4.         Dim discount As Decimal = 0
  5.         Dim dis As Decimal
  6.         If qty >= 5 AndAlso member = "y" Then
  7.             dis = 456 * 10 / 100
  8.             discount = 456 - dis
  9.             total = qty * discount
  10.         ElseIf qty < 5 AndAlso member = "y" Then
  11.             dis = 456 * 5 / 100
  12.             discount = 456 - dis
  13.             total = qty * discount
  14.         ElseIf qty > 5 AndAlso member = "n" Then
  15.             dis = 456 * 5 / 100
  16.             discount = 456 - dis
  17.             total = qty * discount
  18.         Else
  19.             discount = 456
  20.             total = qty * discount
  21.         End If
  22.         Console.WriteLine("Discount = " & discount & " baht" & vbCrLf & "Total = " & total & " baht")
  23.     End Function
  24.     Sub Main()
  25.         Dim qty As Integer
  26.         Dim member As String
  27.         Console.WriteLine("How many VCD(s)?")
  28.         qty = Console.ReadLine()
  29.         Console.WriteLine("Are you Member? (y/n)")
  30.         member = Console.ReadLine()
  31.         vcd(qty, member)
  32.     End Sub

  33. End Module
คัดลอกไปที่คลิปบอร์ด


ตัวอย่าง ผลรัน

2010-01-19_200327.jpg


2010-01-19_200343.jpg




รับทำเว็บ PHP+MySQL
คุณต้องเข้าสู่ระบบก่อนจึงจะสามารถตอบกลับ เข้าสู่ระบบ | ลงทะเบียน

รูปแบบข้อความล้วน|โทรศัพท์มือถือ|เด็กคอมพ์ชิตี้

GMT+7, 2012-5-21 04:58 , Processed in 0.041290 second(s), 16 queries , Gzip On.

Powered by Discuz! X2

© 2001-2011 Comsenz Inc. Page Ranking Tool

ขึ้นไปด้านบน