WEB TIP/ASP

쿠폰번호 생성(랜덤번호)

제프 2008. 6. 17. 12:26

<%

Function MyRandom( couponLength, couponString )

     Const defaultString = "ABCDEFGHIJKLMNOPQRSTUVXYZ0123456789"
     Dim nCount, sRet, nNumber, nLength

     Randomize 'init random

     If couponString = "" Then
          couponString = defaultString  
     End If

     nLength = Len( couponString )

     For nCount = 1 To couponLength
          nNumber = Int((nLength * Rnd) + 1)
          sRet = sRet & Mid( couponString, nNumber, 1 )
     Next

     '리턴값
     MyRandom = sRet

End Function

%>

<%
Response.Write "쿠폰넘버: " & MyRandom( 15, "" )
%>