Jump to content

find winning number


bosco

Recommended Posts

I am new in asp programming, have experience in visual basic programming,I have this problem in converting my visual basic program to asp or visualbasicscript. The case is like this, I have a database with table consisting of the list of the number combination( 6 combinations), I have another table consisting of the winning combination, I want to make a code that will check the list of combination with that of the winning number and also find out how many numbers are the same with the winning combinations. Can anybody help me in coding in asp or visualbasicscript.here is the code in visual basic that is working;Private Sub cmdCheck_Click()On Error Resume NextDim stDate As String'Dim t(5)stDate = txtDate.TextDim lngRecCount As IntegerDim lngCounter As IntegerSet rstBet = New ADODB.RecordsetrstBet.Open "SELECT listahan.d1, listahan.d2, listahan.d3, listahan.d4, listahan.d5, listahan.d6, listahan.date, listahan.lagay FROM listahan;", db, adOpenStatic, adLockOptimisticrstBet.Filter = "[date]=#" & stDate & "#"With rstBet If .RecordCount > 0 Then stRecord = rstBet.RecordCount .MoveFirst For i = 1 To .RecordCount t(0) = rstBet![d1] t(1) = rstBet![d2] t(2) = rstBet![d3] t(3) = rstBet![d4] t(4) = rstBet![d5] t(5) = rstBet![d6] Call IlanTama .MoveNext Next i Else End IfEnd With MsgBox "tapos na ang pagcheck ng mga taya"End SubPrivate Sub cmdLoad_Click()On Error Resume NextDim stDate As StringstDate = txtDate.TextDim lngRecCount As IntegerDim lngCounter As IntegerDim rstTaya As ADODB.RecordsetSet rstTaya = New ADODB.RecordsetrstTaya.Open "SELECT win_42.d1, win_42.d2, win_42.d3, win_42.d4, win_42.d5, win_42.d6, win_42.petsa From win_42", db, adOpenStatic, adLockOptimisticrstTaya.Filter = "[petsa]=#" & stDate & "#"With rstTaya If .RecordCount > 0 Then stRecord = rstTaya.RecordCount .MoveFirst For i = 1 To .RecordCount If stDate = rstTaya![petsa] Then foundFlag = True .MoveFirst d(0) = rstTaya![d1] d(1) = rstTaya![d2] d(2) = rstTaya![d3] d(3) = rstTaya![d4] d(4) = rstTaya![d5] d(5) = rstTaya![d6] i = .RecordCount End If If foundFlag = False Then .MoveNext End If Next i If foundFlag = True Then 'MsgBox "Record has been located!" Else MsgBox "No Match in database!" foundFlag = False .MoveFirst End If Else MsgBox "Circuit is not listed in database!" foundFlag = False End If End With End SubPrivate Sub Form_Load()Set db = New Connectiondb.CursorLocation = adUseClient db.Open "PROVIDER=MSDataShape;Data PROVIDER=" & _ "Microsoft.Jet.OLEDB.4.0;Data Source=" _ & App.Path & "\gkb.mdb;"End SubPrivate Function IlanTama()Dim mybet As DoubleDim ilanpanalo As Integer'ReDim t(5)ilanpanalo = 0Dim x ' first digit tamaDim y ' first digit tayaFor x = 0 To 5 For y = 0 To 5 If d(x).Text = t(y).Text Then ilanpanalo = ilanpanalo + 1 End If NextNextSelect Case ilanpanaloCase Is = 0, 1, 2 rstBet![lagay] = "talo" rstBet.UpdateCase Is = 3 rstBet![lagay] = "balik taya" rstBet.UpdateCase Is = 4 rstBet![lagay] = "800" rstBet.UpdateCase Is = 5 rstBet![lagay] = "20000" rstBet.UpdateCase Is = 6 rstBet![lagay] = "Jackpot" rstBet.UpdateEnd SelectEnd Function

Link to comment
Share on other sites

  • 3 weeks later...

Not sure I understood the question or if this is any help but it may get you started on the right track. After all, it's another hour until I usually wake up. Think you may be better off letting the database do all the work and try not to use the on error clause, (it will probably bring back undesired results if the script fails unless you set up some form of error control).Select the following and save it as an asp page:<%'--------------------------'Variables'-------------------------- thisDate = date() my_numbers = ",5,16,10,30,31,32" my_nos = my_numbers win_list = ",10,20,30,31,32,40," win_list = numeric2(win_list) 'This will strip out any data that isn't a number or comma match_count = 0 match_list = ""'--------------------------'Check Results'-------------------------- newSplit = split(my_numbers,",") For each my_numbers in newSplit check_number = numeric(my_numbers) if instr(win_list, ","&check_number&",")>0 then match_count = match_count + 1 match_list = match_list &","& check_number end if Next'--------------------------'Check Prizes'-------------------------- select case(match_count) case 3 prize = "balik taya" case 4 prize = "800" case 5 prize = "20000" case 6 prize = "Jackpot" case else prize = "talo" end select'--------------------------'Highlight Matches'-------------------------- if win_list<>"" then newSplit = split(match_list,",") For e = 1 to ubound(newSplit) win_list = replace(win_list,","&newSplit(e)&"," , ",<font color='#FF0000'><b>"&newSplit(e)&"</b></font>,") Next end if'--------------------------'Functions'-------------------------- function numeric(iStr) strValidChars = "0123456789" iWord = "" if iStr<>"" then For i=1 to len(iStr) iChar = mid(iStr,i,1) if instr(strValidChars,iChar)>0 then iWord = iWord & iChar Next end if numeric = iWord end function function numeric2(iStr) strValidChars = "0123456789," iWord = "" if iStr<>"" then For i=1 to len(iStr) iChar = mid(iStr,i,1) if instr(strValidChars,iChar)>0 then iWord = iWord & iChar Next end if numeric2 = iWord end function'--------------------------'Test'--------------------------' response.write prize &"<br />"' response.write win_list &"<br />"' response.write my_nos &"<br />"' response.write match_count &"<br />"' response.write match_list &"<br />"%><table border="1" width="100%"> <tr> <td>DATE</td> <td><%=thisDate%> </td> </tr> <tr> <td>RESULT</td> <td><%=win_list%> </td> </tr> <tr> <td>MATCHED NUMBERS</td> <td><%=match_list%> </td> </tr> <tr> <td>MATCHES</td> <td><%=match_count%> </td> </tr> <tr> <td>PRIZE</td> <td><%=prize%> </td> </tr></table>If that is along the right lines all you have to do is substitute the variables:my_numbers (with the numbers you are going to check)win_list (with the resultant numbers from the database query).Bear in mind that if you wanted to check on the press of a button using this method (asp) you would have to reload the page to make this code execute.Let me know how it goes.Cheers

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...