Wednesday, December 16, 2015

5:35 PM
แปะกันลืม : ไปเจอ script ของฝรั่งในการ random ค่าที่เราต้องการมา ซึ่งได้ใช้บ่อย ก็เลยเอามาแปะไว้ก่อน ยามจะใช้ก็มาค้นหาเอาอีกที
วิธีการสร้างก็ไม่ยาก copy script ไปแปะใน custom function แล้วก็กำหนดตัวแปร start, stop เสีย จากนั้นก็เอาไปใช้งานได้เลย  แค่กำหนดช่วงที่เราต้องการ random เข้าไปใน script ก็แจ่มแล้ว

Custom Function : rand(start,stop)

Let([

start = If ( start < 0 ; start - 1 ; start );
stop = If ( start < 0 and stop < 0 ; stop - 1 ; stop );

// ทดสอบค่า
result = Truncate ( ( Random * ( stop - ( start - 1 ))) + start ; 0 )

];

// ส่งออกค่า
result

)

บทความอื่นๆ