Just nu i M3-nätverket
Gå till innehåll

databasarbete i vb


kryxz

Rekommendera Poster

är värdelös på vb.. men nu måste d användas =) har en asp sida som är kodad i vb får dock upp fel hela tiden vilket följande kod är källan till förstår dock inte varför så jag kan inte rätta till d.. kan ngn hjälpa mig?

 

 

Sub Gameover()

MsgBox "Game Over!", , "TET"

window.clearInterval Timer1

GOver = true

 

AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _

"Dbq=Server.MapPath("\kryxz\private\users.mdb");"

 

Conn1.Open AccessConnect

Set rs = Conn1.Execute("SELECT * FROM tetris_highscore")

 

rs.AddNew

 

rs("Username") = "kryxz"

rs("poang") = score

rs("date") = date

 

rs.Update

Rs1.Close

Conn1.Close

 

End Sub

Länk till kommentar
Dela på andra webbplatser

har fått upp så måånga olika felmeddelande nu att jag vet inte vilket jag ska skriva.. men koden ser lite annorlunda ut nu o jag vet så mkt som att d e server.creatobject som klöddar.. tydligen eftersom server objektet inte finns i vb.. tar jag bort "server." så får jag ett skript som utnyttjar 100% av min cpu =)

 

Länk till kommentar
Dela på andra webbplatser

Stefan B Karlsson

Tjena, så här kan du göra:

Sub GameOVer()
   'Sätt först referens till
   'Microsoft ActiveX Data Objects 2.7 Library
   '(2.7 eller tidigare duger)
   Dim conn1 As ADODB.Connection
   Set conn1 = New ADODB.Connection
   conn1.Provider = "Microsoft.Jet.OLEDB.4.0"
   conn1.Open App.Path & "\users.mdb"
   sql = "insert into tetris_highscore (Username,poang,date) values('%1','%2','%3')"
   sql = Replace(sql, "%1", "kryxz")
   sql = Replace(sql, "%2", score)
   sql = Replace(sql, "%3", Date)

   conn1.Execute sql
   conn1.Close

End Sub

 

Recordsetobjektet behövs inte för att inserta en rad i databasen utan du kan använda conn1.execute enbart, du ska ju inte göra något med resultatet.

 

Vill du få tillbaka ett resultat som du kan bearbeta så dimensionerar du helt enkelt upp ett recordsetobjekt och kör en

set rs=conn1.execute(sql)

då innehåller rs det returnerade recordset:et.

 

 

mvh /

Stefan Karlsson

ITmaskinen.se

 

 

[inlägget ändrat 2002-12-17 20:36:59 av Stefan B Karlsson]

Länk till kommentar
Dela på andra webbplatser

nä.. får inte rätt på d.. postar hela scriptet så får ni se om ni hittar ngt fel.. scriptet är ett tetris spel jag hittade på nätet o d första jag tänkte på då när jag skulle använda d till ngt var ju givetvis en topplista.. fixa fram topplistan gör jag enkelt i vanlig asp sen.. e mest hur jag skickar in datan i databasen som är preoblemet.. mina kunskaper om kod som ser ut så här e i princip nada =)

 

kod:

 

<%

'Original Code Programmed by Anton Gustavsson and Marcus Mason in vb6.0

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'Modifications like Levels , speeds, other functions and adapted to vbscript by Felipe Arteaga

%>

<%If Not Request.QueryString("Ven") = "T" then%>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<TITLE></TITLE>

</HEAD>

<SCRIPT LANGUAGE=vbscript>

function Redir()

window.open "<%= right(Request.ServerVariables("SCRIPT_NAME"),len(Request.ServerVariables("SCRIPT_NAME"))-instrrev(Request.ServerVariables("SCRIPT_NAME"),"/",len(Request.ServerVariables("SCRIPT_NAME"))))%>?Ven=T","user","status=no,toolbar=no,menubar=no,height=456,width=304,top=100,left=100,scrollbars=no"

window.history.back(-1)

End function

</SCRIPT>

<BODY onload=Redir()>

</BODY>

</HTML>

<%else%>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<TITLE>~~ VBScript TET ~~~~~~~~~~~~~~~~~~</TITLE>

<Style Type="text/css">

<!--

.normalHI{font-family:verdana,helvetica,arial,sans serif;color:#FFCC00;font-size:10pt;font-weight:bold;Cursor:hand;}

.normalH{font-family:verdana,helvetica,arial,sans serif;color:#000000;font-size:10pt;font-weight:bold;Cursor:hand;}

.normalG{font-family:verdana,helvetica,arial,sans serif;color:#000000;font-size:13pt;font-weight:bold;}

.normal{font-family:verdana,helvetica,arial,sans serif;color:#000000;font-size:10pt;font-weight:bold;}

.normalD{font-family:verdana,helvetica,arial,sans serif;color:#000000;font-size:10pt;font-weight:bold;}

.normalI{font-family:verdana,helvetica,arial,sans serif;color:#00FF00;font-size:10pt;font-weight:bold;}

.normalO{font-family:verdana,helvetica,arial,sans serif;color:#FFFF00;font-size:10pt;font-weight:bold;}

-->

</Style>

</HEAD>

<BODY topmargin=2 leftmargin=2>

<div align="center">

<center>

<table border="0" width="300" cellspacing="0" cellpadding="0"><tr><td width="200">

<center>

<table border="1" bordercolor="#000000" cellspacing="0" cellpadding="0" bgcolor="#000000">

<tr height="18">

<td ID="240" width="18"></td><td ID="241" width="18"></td><td ID="242" width="18"></td><td ID="243" width="18"></td><td ID="244" width="18"></td>

<td ID="245" width="18"></td><td ID="246" width="18"></td><td ID="247" width="18"></td><td ID="248" width="18"></td><td ID="249" width="18"></td>

</tr>

<tr height="18">

<td ID="230" width="18"></td><td ID="231" width="18"></td><td ID="232" width="18"></td><td ID="233" width="18"></td><td ID="234" width="18"></td>

<td ID="235" width="18"></td><td ID="236" width="18"></td><td ID="237" width="18"></td><td ID="238" width="18"></td><td ID="239" width="18"></td>

</tr>

<tr height="18">

<td ID="220" width="18"></td><td ID="221" width="18"></td><td ID="222" width="18"></td><td ID="223" width="18"></td><td ID="224" width="18"></td>

<td ID="225" width="18"></td><td ID="226" width="18"></td><td ID="227" width="18"></td><td ID="228" width="18"></td><td ID="229" width="18"></td>

</tr>

<tr height="18">

<td ID="210" width="18"></td><td ID="211" width="18"></td><td ID="212" width="18"></td><td ID="213" width="18"></td><td ID="214" width="18"></td>

<td ID="215" width="18"></td><td ID="216" width="18"></td><td ID="217" width="18"></td><td ID="218" width="18"></td><td ID="219" width="18"></td>

</tr>

<tr height="18">

<td ID="200" width="18"></td><td ID="201" width="18"></td><td ID="202" width="18"></td><td ID="203" width="18"></td><td ID="204" width="18"></td>

<td ID="205" width="18"></td><td ID="206" width="18"></td><td ID="207" width="18"></td><td ID="208" width="18"></td><td ID="209" width="18"></td>

</tr>

<tr height="18">

<td ID="190" width="18"></td><td ID="191" width="18"></td><td ID="192" width="18"></td><td ID="193" width="18"></td><td ID="194" width="18"></td>

<td ID="195" width="18"></td><td ID="196" width="18"></td><td ID="197" width="18"></td><td ID="198" width="18"></td><td ID="199" width="18"></td>

</tr>

<tr height="18">

<td ID="180" width="18"></td><td ID="181" width="18"></td><td ID="182" width="18"></td><td ID="183" width="18"></td><td ID="184" width="18"></td>

<td ID="185" width="18"></td><td ID="186" width="18"></td><td ID="187" width="18"></td><td ID="188" width="18"></td><td ID="189" width="18"></td>

</tr>

<tr height="18">

<td ID="170" width="18"></td><td ID="171" width="18"></td><td ID="172" width="18"></td><td ID="173" width="18"></td><td ID="174" width="18"></td>

<td ID="175" width="18"></td><td ID="176" width="18"></td><td ID="177" width="18"></td><td ID="178" width="18"></td><td ID="179" width="18"></td>

</tr>

<tr height="18">

<td ID="160" width="18"></td><td ID="161" width="18"></td><td ID="162" width="18"></td><td ID="163" width="18"></td><td ID="164" width="18"></td>

<td ID="165" width="18"></td><td ID="166" width="18"></td><td ID="167" width="18"></td><td ID="168" width="18"></td><td ID="169" width="18"></td>

</tr>

<tr height="18">

<td ID="150" width="18"></td><td ID="151" width="18"></td><td ID="152" width="18"></td><td ID="153" width="18"></td><td ID="154" width="18"></td>

<td ID="155" width="18"></td><td ID="156" width="18"></td><td ID="157" width="18"></td><td ID="158" width="18"></td><td ID="159" width="18"></td>

</tr>

<tr height="18">

<td ID="140" width="18"></td><td ID="141" width="18"></td><td ID="142" width="18"></td><td ID="143" width="18"></td><td ID="144" width="18"></td>

<td ID="145" width="18"></td><td ID="146" width="18"></td><td ID="147" width="18"></td><td ID="148" width="18"></td><td ID="149" width="18"></td>

</tr>

<tr height="18">

<td ID="130" width="18"></td><td ID="131" width="18"></td><td ID="132" width="18"></td><td ID="133" width="18"></td><td ID="134" width="18"></td>

<td ID="135" width="18"></td><td ID="136" width="18"></td><td ID="137" width="18"></td><td ID="138" width="18"></td><td ID="139" width="18"></td>

</tr>

<tr height="18">

<td ID="120" width="18"></td><td ID="121" width="18"></td><td ID="122" width="18"></td><td ID="123" width="18"></td><td ID="124" width="18"></td>

<td ID="125" width="18"></td><td ID="126" width="18"></td><td ID="127" width="18"></td><td ID="128" width="18"></td><td ID="129" width="18"></td>

</tr>

<tr height="18">

<td ID="110" width="18"></td><td ID="111" width="18"></td><td ID="112" width="18"></td><td ID="113" width="18"></td><td ID="114" width="18"></td>

<td ID="115" width="18"></td><td ID="116" width="18"></td><td ID="117" width="18"></td><td ID="118" width="18"></td><td ID="119" width="18"></td>

</tr>

<tr height="18">

<td ID="100" width="18"></td><td ID="101" width="18"></td><td ID="102" width="18"></td><td ID="103" width="18"></td><td ID="104" width="18"></td>

<td ID="105" width="18"></td><td ID="106" width="18"></td><td ID="107" width="18"></td><td ID="108" width="18"></td><td ID="109" width="18"></td>

</tr>

<tr height="18">

<td ID="90" width="18"></td><td ID="91" width="18"></td><td ID="92" width="18"></td><td ID="93" width="18"></td><td ID="94" width="18"></td>

<td ID="95" width="18"></td><td ID="96" width="18"></td><td ID="97" width="18"></td><td ID="98" width="18"></td><td ID="99" width="18"></td>

</tr>

<tr height="18">

<td ID="80" width="18"></td><td ID="81" width="18"></td><td ID="82" width="18"></td><td ID="83" width="18"></td><td ID="84" width="18"></td>

<td ID="85" width="18"></td><td ID="86" width="18"></td><td ID="87" width="18"></td><td ID="88" width="18"></td><td ID="89" width="18"></td>

</tr>

<tr height="18">

<td ID="70" width="18"></td><td ID="71" width="18"></td><td ID="72" width="18"></td><td ID="73" width="18"></td><td ID="74" width="18"></td>

<td ID="75" width="18"></td><td ID="76" width="18"></td><td ID="77" width="18"></td><td ID="78" width="18"></td><td ID="79" width="18"></td>

</tr>

<tr height="18">

<td ID="60" width="18"></td><td ID="61" width="18"></td><td ID="62" width="18"></td><td ID="63" width="18"></td><td ID="64" width="18"></td>

<td ID="65" width="18"></td><td ID="66" width="18"></td><td ID="67" width="18"></td><td ID="68" width="18"></td><td ID="69" width="18"></td>

</tr>

<tr height="18">

<td ID="50" width="18"></td><td ID="51" width="18"></td><td ID="52" width="18"></td><td ID="53" width="18"></td><td ID="54" width="18"></td>

<td ID="55" width="18"></td><td ID="56" width="18"></td><td ID="57" width="18"></td><td ID="58" width="18"></td><td ID="59" width="18"></td>

</tr>

<tr height="18">

<td ID="40" width="18"></td><td ID="41" width="18"></td><td ID="42" width="18"></td><td ID="43" width="18"></td><td ID="44" width="18"></td>

<td ID="45" width="18"></td><td ID="46" width="18"></td><td ID="47" width="18"></td><td ID="48" width="18"></td><td ID="49" width="18"></td>

</tr>

<tr height="18">

<td ID="30" width="18"></td><td ID="31" width="18"></td><td ID="32" width="18"></td><td ID="33" width="18"></td><td ID="34" width="18"></td>

<td ID="35" width="18"></td><td ID="36" width="18"></td><td ID="37" width="18"></td><td ID="38" width="18"></td><td ID="39" width="18"></td>

</tr>

<tr height="18">

<td ID="20" width="18"></td><td ID="21" width="18"></td><td ID="22" width="18"></td><td ID="23" width="18"></td><td ID="24" width="18"></td>

<td ID="25" width="18"></td><td ID="26" width="18"></td><td ID="27" width="18"></td><td ID="28" width="18"></td><td ID="29" width="18"></td>

</tr>

<tr height="18">

<td ID="10" width="18"></td><td ID="11" width="18"></td><td ID="12" width="18"></td><td ID="13" width="18"></td><td ID="14" width="18"></td>

<td ID="15" width="18"></td><td ID="16" width="18"></td><td ID="17" width="18"></td><td ID="18" width="18"></td><td ID="19" width="18"></td>

</tr>

<tr height="18">

<td ID="0" width="18"></td><td ID="1" width="18"></td><td ID="2" width="18"></td><td ID="3" width="18"></td><td ID="4" width="18"></td>

<td ID="5" width="18"></td><td ID="6" width="18"></td><td ID="7" width="18"></td><td ID="8" width="18"></td><td ID="9" width="18"></td>

</tr>

</table>

</center>

</td>

<td width="100">

<table border="1" bordercolor="#000000" height="452" width="100" cellspacing="0" cellpadding="0">

<tr height="30">

<td class=normalG align=center bgcolor="#FFFF00">~TET~</td>

</tr>

<tr height="20">

<td class=normalD align=center bgcolor="#FFCC00">Preview</td>

</tr>

<tr height="100">

<td bgcolor="#FFCC00">

<!-- Inicio Preview -->

<div align="center"><center><table border="1" cellspacing="0" cellpadding="0" bgcolor="#000000">

<tr height="18">

<td ID="P0" width="18"></td><td ID="P1" width="18"></td><td ID="P2" width="18"></td><td ID="P3" width="18"></td>

</tr>

<tr height="18">

<td ID="P4" width="18"></td><td ID="P5" width="18"></td><td ID="P6" width="18"></td><td ID="P7" width="18"></td>

</tr>

<tr height="18">

<td ID="P8" width="18"></td><td ID="P9" width="18"></td><td ID="P10" width="18"></td><td ID="P11" width="18"></td>

</tr>

</table></center></div>

<!-- Fin Preview -->

</td>

</tr>

<tr height="32">

<td ID="Sco01" align=center bgcolor="#009900" class=normalh onmouseover=Mmove('I') onmouseout=Mmove('O')>Score</td>

</tr>

<tr height="32">

<td ID="Sco02" align=center bgcolor="#FFFF00" class=normalh>0</td>

</tr>

<tr height="32">

<td ID="In01" align=center bgcolor="#009900" class=normal onmouseover=Mmove('I') onmouseout=Mmove('O')>Level</td>

</tr>

<tr height="32">

<td ID="In02" align=center bgcolor="#FFFF00" class=normal>1</td>

</tr>

<tr height="32">

<td ID="In05" align=center bgcolor="#009900" class=normalh onmouseover=Mmove('I') onmouseout=Mmove('O')>Blocks</td>

</tr>

<tr height="32">

<td ID="In06" align=center bgcolor="#FFFF00" class=normalh>1</td>

</tr>

<tr height="32">

<td ID="In03" align=center bgcolor="#009900" class=normalh onclick=Iniciar('i') onmouseover=Mmove('I') onmouseout=Mmove('O')>Start</td>

</tr>

<tr height="32">

<td ID="In04" align=center bgcolor="#009900" class=normalh onclick=Iniciar('d') onmouseover=Mmove('I') onmouseout=Mmove('O')>Stop</td>

</tr>

<tr height="38">

<td ID="In09" align=center bgcolor="#009900" class=normalh onclick=self.close() onmouseover=Mmove('I') onmouseout=Mmove('O')>Close Window</td>

</tr>

</table>

</td></tr></table></center></div>

</BODY>

<SCRIPT LANGUAGE=vbscript>

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Dim Timer1,HastIni,LevlIni,Namn,Score,Levl,Hast,Fig,Fig2,Farg,Farg2,X,Y,Rot,Rot2,tratt,Pausa,ScrPau,Pos,GOver

Dim hs(),sor(),hsant(),n(),s(),s2(),s3()

redim hs(3, 15, 2):redim sor(3, 15):redim hsant(3):redim n(10, 25):redim s(5, 4):redim s2(4, 4):redim s3(4, 4)

LevlIni = 1

Pausa = False

HastIni = VelLevel(LevlIni)

Hast = HastIni

Levl = LevlIni

Pos = Levl - 1

ColorForm

GOver = false

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

function Iniciar(ind)

if ind = "i" then

score = 0

GOver = false

Hast = HastIni

Levl = LevlIni

Pos = PosLevel(Levl)

For i = 1 To 4:For i2 = 1 To 4:s2(i, i2) = False:Next:Next

For i = 1 To 10:For i2 = 1 To 25:n(i, i2) = False:Next:Next

Timer1 = window.setInterval("Andar()",Hast)

ColorForm

Fig2 = 0

Nyfig

else

window.clearInterval Timer1

end if

end function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Sub Nyfig()

Pos = Pos + 1

document.all("In06").innertext = Pos

Select Case Pos

Case 30: Levl = 2: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 60: Levl = 3: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 90: Levl = 4: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 120: Levl = 5: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 150: Levl = 6: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 180: Levl = 7: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 210: Levl = 8: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 240: Levl = 9: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 270: Levl = 10: Hast = VelLevel(Levl): window.In02.innerText = Levl

Case 300: Levl = 11: Hast = VelLevel(Levl): window.In02.innerText = Levl

End Select

window.clearInterval Timer1

Timer1 = window.setInterval("Andar()",Hast)

Fig = Fig2

Farg = Farg2

Fig2 = Int(Rnd * 7) + 1

X = 4

Y = 26

Rot = 1

For i = 1 To 4:For i2 = 1 To 4:s(i, i2) = s2(i, i2):s2(i, i2) = 0:Next:Next

Select Case Fig2

Case 1:s2(2, 2) = True:s2(3, 2) = True:s2(2, 3) = True:s2(3, 3) = True:Farg2 = "#FF0000"

Case 2:s2(1, 2) = True:s2(2, 2) = True:s2(3, 2) = True:s2(4, 2) = True:Farg2 = "#33CC33"

Case 3:s2(2, 1) = True:s2(3, 1) = True:s2(3, 2) = True:s2(3, 3) = True:Farg2 = "#FF9900"

Case 4:s2(3, 1) = True:s2(2, 1) = True:s2(2, 2) = True:s2(2, 3) = True:Farg2 = "#666666"

Case 5:s2(3, 1) = True:s2(3, 2) = True:s2(3, 3) = True:s2(2, 2) = True:Farg2 = "#CC00CC"

Case 6:s2(2, 1) = True:s2(2, 2) = True:s2(3, 2) = True:s2(3, 3) = True:Farg2 = "#6666FF"

Case 7:s2(3, 1) = True:s2(3, 2) = True:s2(2, 2) = True:s2(2, 3) = True:Farg2 = "#33CCCC"

End Select

For i = 1 To 4

For i2 = 1 To 3

document.all("P" & cstr(((i2 - 1) * 4 + i - 1))).bgcolor = "#000000"

If s2(i, i2) = True Then

document.all("P" & cstr((i2 - 1) * 4 + i - 1)).bgcolor = Farg2

End If

Next

Next

End Sub

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Function PosLevel(Lev)

Select Case Lev

Case 1: PosLevel = 1

Case 2: PosLevel = 51

Case 3: PosLevel = 81

Case 4: PosLevel = 111

Case 5: PosLevel = 141

Case 6: PosLevel = 181

Case 7: PosLevel = 221

Case 8: PosLevel = 261

Case 9: PosLevel = 301

Case 10: PosLevel = 341

End Select

End Function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Function VelLevel(Velo)

Select Case Velo

Case 1: VelLevel = 500

Case 2: VelLevel = 450

Case 3: VelLevel = 400

Case 4: VelLevel = 350

Case 5: VelLevel = 300

Case 6: VelLevel = 250

Case 7: VelLevel = 200

Case 8: VelLevel = 150

Case 9: VelLevel = 100

Case 10: VelLevel = 50

Case 11: VelLevel = 10

End Select

End Function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Sub ColorForm()

For i = 0 To 11:document.all("P" & cstr(i)).bgcolor = "#000000":Next

For i = 0 To 249:document.all(cstr(i)).bgcolor = "#000000":Next

End Sub

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

function Andar()

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True And Y - i2 + 1 = 1 Then Fig = 0

If Y - i2 > 0 And X + i - 1 > 0 And X + i - 1 < 11 Then

If s(i, i2) = True And n(X + i - 1, Y - i2) = True Then Fig = 0

End If

Next

Next

If Fig = 0 Then

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True Then n(X + i - 1, Y - i2 + 1) = True

Next

Next

Ner

Nyfig

Else

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True And s(i, i2 - 1) = False Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = "#000000"

End If

Next

Next

End If

Y = Y - 1

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True Then

if not gover = true then

If ucase(document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor) <> "#000000" And ucase(document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor) <> Farg Then

Gameover

end if

end if

End If

If s(i, i2) = True Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = Farg

End If

Next

Next

end function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Sub Gameover()

MsgBox "Game Over!", , "TET"

window.clearInterval Timer1

GOver = true

 

'Sätt först referens till

'Microsoft ActiveX Data Objects 2.7 Library

'(2.7 eller tidigare duger)

Dim conn1 As ADODB.Connection

Set conn1 = New ADODB.Connection

conn1.Provider = "Microsoft.Jet.OLEDB.4.0"

conn1.Open App.Path & "\users.mdb"

sql = "insert into tetris_highscore (Username,poang,date) values('%1','%2','%3')"

sql = Replace(sql, "%1", "kryxz")

sql = Replace(sql, "%2", Score)

sql = Replace(sql, "%3", Date)

 

conn1.Execute sql

conn1.Close

 

 

End Sub

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Sub Ner()

Score = Score + 10

document.all("Sco02").innertext = Score

For i2 = 25 To 1 Step -1

ok = 1

For i = 1 To 10

If n(i, i2) = False Then ok = 0

Next

If ok = 1 Then

Score = Score + 150

document.all("Sco02").innertext = Score

For i = 1 To 10

For i3 = i2 To 24

n(i, i3) = n(i, i3 + 1)

document.all(cstr(coor(i, i3))).bgcolor = document.all(cstr(coor(i, i3 + 1))).bgcolor

Next

Next

End If

Next

End Sub

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Function coor(xx, yy)

coor = (yy - 1) * 10 + xx - 1

End Function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Sub Rota()

Rot2 = Rot + 1

If Rot2 = 5 Then Rot2 = 1

If (Fig = 2 Or Fig > 5) And Rot2 = 3 Then Rot2 = 1

For i = 1 To 4

For i2 = 1 To 4

s3(i, i2) = 0

Next

Next

Select Case Fig

Case 2

Select Case Rot2

Case 1:s3(1, 2) = True:s3(2, 2) = True:s3(3, 2) = True:s3(4, 2) = True

Case 2:s3(2, 1) = True:s3(2, 2) = True:s3(2, 3) = True:s3(2, 4) = True

End Select

Case 3

Select Case Rot2

Case 1:s3(2, 1) = True:s3(3, 1) = True:s3(3, 2) = True:s3(3, 3) = True

Case 2:s3(4, 1) = True:s3(4, 2) = True:s3(3, 2) = True:s3(2, 2) = True

Case 3:s3(3, 3) = True:s3(2, 3) = True:s3(2, 2) = True:s3(2, 1) = True

Case 4:s3(2, 2) = True:s3(2, 1) = True:s3(3, 1) = True:s3(4, 1) = True

End Select

Case 4

Select Case Rot2

Case 1:s3(3, 1) = True:s3(2, 1) = True:s3(2, 2) = True:s3(2, 3) = True

Case 2:s3(2, 1) = True:s3(3, 1) = True:s3(4, 1) = True:s3(4, 2) = True

Case 3:s3(3, 1) = True:s3(3, 2) = True:s3(3, 3) = True:s3(2, 3) = True

Case 4:s3(2, 1) = True:s3(2, 2) = True:s3(3, 2) = True:s3(4, 2) = True

End Select

Case 5

Select Case Rot2

Case 1:s3(3, 1) = True:s3(3, 2) = True:s3(3, 3) = True:s3(2, 2) = True

Case 2:s3(3, 1) = True:s3(2, 2) = True:s3(3, 2) = True:s3(4, 2) = True

Case 3:s3(2, 1) = True:s3(2, 2) = True:s3(2, 3) = True:s3(3, 2) = True

Case 4:s3(2, 1) = True:s3(3, 1) = True:s3(4, 1) = True:s3(3, 2) = True

End Select

Case 6

Select Case Rot2

Case 1:s3(2, 1) = True:s3(2, 2) = True:s3(3, 2) = True:s3(3, 3) = True

Case 2:s3(2, 2) = True:s3(3, 2) = True:s3(3, 1) = True:s3(4, 1) = True

End Select

Case 7

Select Case Rot2

Case 1:s3(3, 1) = True:s3(3, 2) = True:s3(2, 2) = True:s3(2, 3) = True

Case 2:s3(2, 1) = True:s3(3, 1) = True:s3(3, 2) = True:s3(4, 2) = True

End Select

End Select

ok = 1

For i = 1 To 4

For i2 = 1 To 4

If s3(i, i2) = True Then

If X + i - 1 < 1 Or X + i - 1 > 10 Or Y - i2 + 1 < 1 Then ok = 0

If ok = 1 Then

If n(X + i - 1, Y - i2 + 1) = True Then ok = 0

End If

End If

Next

Next

If ok = 0 Then Exit Sub

Rot = Rot2

For i = 1 To 4

For i2 = 1 To 4

If s3(i, i2) = True And s(i, i2) = False Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = Farg

End If

If s3(i, i2) = False And s(i, i2) = True Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = "#000000"

End If

s(i, i2) = s3(i, i2)

Next

Next

End Sub

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Sub document_onkeydown

If window.event.keyCode = 27 Then msgbox "Pause",,"TET"

If window.event.keyCode = 80 Or window.event.keyCode = 114 Then iniciar("d")

If window.event.keyCode = 113 Then iniciar("i")

If Not Pausa = True Then

If window.event.keyCode = 38 And Fig > 1 Then Rota

If window.event.keyCode = 37 Then

ok = 1

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True And X + i - 1 - 1 > 0 Then

If n(X + i - 1 - 1, Y - i2 + 1) = True Then ok = 0

End If

If s(i, i2) = True And X + i - 1 - 1 < 1 Then ok = 0

Next

Next

If ok = 1 Then

X = X - 1

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True Then

If s(i + 1, i2) = False Then

document.all(cstr(coor(X + i, Y - i2 + 1))).bgcolor = "#000000"

End If

End If

If s(i, i2) = True Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = Farg

End If

Next

Next

End If

End If

If window.event.keyCode = 39 Then

ok = 1

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True And X + i - 1 + 1 < 11 Then

If n(X + i - 1 + 1, Y - i2 + 1) = True Then ok = 0

End If

If s(i, i2) = True And X + i - 1 + 1 > 10 Then ok = 0

Next

Next

If ok = 1 Then

X = X + 1

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True Then

If s(i - 1, i2) = False Then

document.all(cstr(coor(X + i - 2, Y - i2 + 1))).bgcolor = "#000000"

End If

End If

If s(i, i2) = True Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = Farg

End If

Next

Next

End If

End If

'Aqui

If window.event.keyCode = 32 Or window.event.keyCode = 40 Then

If Fig > 0 Then

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = "#000000"

End If

Next

Next

Do

Y = Y - 1

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True And Y - i2 + 1 = 1 Then Fig = 0

If Y - i2 > 0 And X + i - 1 > 0 And X + i - 1 < 11 Then

If s(i, i2) = True And n(X + i - 1, Y - i2) = True Then Fig = 0

End If

Next

Next

Loop Until Fig = 0

For i = 1 To 4

For i2 = 1 To 4

If s(i, i2) = True Then

document.all(cstr(coor(X + i - 1, Y - i2 + 1))).bgcolor = Farg

End If

If s(i, i2) = True Then n(X + i - 1, Y - i2 + 1) = True

Next

Next

End If

End If

End If

End Sub

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

function Mmove(Index)

if index = "I" then

document.all(Window.Event.SrcElement.sourceindex).classname = "normalHI"

document.all(Window.Event.SrcElement.sourceindex).bgcolor = "#0099CC"

else

document.all(Window.Event.SrcElement.sourceindex).classname = "normalH"

document.all(Window.Event.SrcElement.sourceindex).bgcolor = "#009900"

end if

end function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

</script>

</HTML>

<%End If%>

 

Länk till kommentar
Dela på andra webbplatser

Stefan B Karlsson

Ah, i titeln på din fråga så står det "databasarbete i VB", så därför visade jag ett vb-exempel på hur man gör, men när man läser ordentligt så ska du ju använda det i en ASP-sida, så då måste vi köra vb-script istället, skillnaden är hur man dimensionerar upp adodb,och hur man anger sökvägen till databasen. Du kan även behöva ändra rättigheter på databasen (modify) och ta bort rättigheten read från katalogen om den ligger i webbens sökväg, så att folk inte kan tanka ner databasen om de vet vart den är.

 

Något sådant borde det bli:

 

Sub GameOVer()

'Vi behöver INTE sätta referens till MS ADO.

Dim conn1

Set Conn1 = Server.CreateObject("ADODB.Connection")

 

conn1.Provider = "Microsoft.Jet.OLEDB.4.0"

conn1.Open Server.MapPath("\kryxz\private\users.mdb")

 

sql = "insert into tetris_highscore (Username,poang,date) values('%1','%2','%3')"

sql = Replace(sql, "%1", "kryxz")

sql = Replace(sql, "%2", score)

sql = Replace(sql, "%3", Date)

 

conn1.Execute sql

conn1.Close

 

End Sub

 

 

mvh /

Stefan Karlsson

ITmaskinen.se

 

Länk till kommentar
Dela på andra webbplatser

Stefan B Karlsson

Hehe.. Och nu när jag läser ditt postade script så ser jag att det är på KLIENTSIDAN som du försöker öppna databasen.. Det kommer nog inte att gå så bra.

Du får posta värderna antingen som formulärvärden eller som querys så att du kan ta emot det på SERVERSIDAN och hantera det där.

 

 

mvh /

Stefan Karlsson

ITmaskinen.se

 

Länk till kommentar
Dela på andra webbplatser

Arkiverat

Det här ämnet är nu arkiverat och är stängt för ytterligare svar.

×
×
  • Skapa nytt...