jo da :)
webform1.aspx:
<%@ Page Language="vb" autoeventwireup="false" codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.Opret" %>
<%@ import Namespace="system.net.mail" %>
<%@ import Namespace="system.security.Cryptography" %>
<%@ import Namespace="system.data.oledb" %>
<%@ import Namespace="system.data" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="style.css" type="text/css" rel="stylesheet">
</HEAD>
<body ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 56px" runat="server"
height="21px" width="144px">*Ønsket
brugernavn<sup>1</sup></asp:label><asp:checkbox id="showtlf" style="Z-INDEX: 130; LEFT: 200px; POSITION: absolute; TOP: 472px" runat="server"
Width="104px" Height="24px"></asp:checkbox><asp:textbox id="beskrivelse" style="Z-INDEX: 128; LEFT: 200px; POSITION: absolute; TOP: 496px"
runat="server" Width="160px" Height="76px" Columns="20" Rows="4" TextMode="MultiLine"></asp:textbox><asp:textbox id="tlf" style="Z-INDEX: 127; LEFT: 200px; POSITION: absolute; TOP: 440px" runat="server"
Width="144px"></asp:textbox><asp:textbox id="skype" style="Z-INDEX: 126; LEFT: 200px; POSITION: absolute; TOP: 408px" runat="server"
Width="144px"></asp:textbox><asp:textbox id="msn" style="Z-INDEX: 125; LEFT: 200px; POSITION: absolute; TOP: 376px" runat="server"
Width="144px"></asp:textbox><asp:textbox id="post" style="Z-INDEX: 124; LEFT: 200px; POSITION: absolute; TOP: 248px" runat="server"
Width="48px" MaxLength="4"></asp:textbox><asp:textbox id="city" style="Z-INDEX: 123; LEFT: 200px; POSITION: absolute; TOP: 216px" runat="server"
Width="144px"></asp:textbox><asp:textbox id="mail" style="Z-INDEX: 122; LEFT: 200px; POSITION: absolute; TOP: 184px" runat="server"
Width="144px"></asp:textbox><asp:textbox id="name" style="Z-INDEX: 121; LEFT: 200px; POSITION: absolute; TOP: 152px" runat="server"
Width="144px"></asp:textbox><asp:textbox id="pass2" style="Z-INDEX: 120; LEFT: 200px; POSITION: absolute; TOP: 120px" runat="server"
Width="144px"></asp:textbox><asp:textbox id="pass" style="Z-INDEX: 119; LEFT: 200px; POSITION: absolute; TOP: 88px" runat="server"
Width="144px"></asp:textbox><asp:label id="Label15" style="Z-INDEX: 115; LEFT: 48px; POSITION: absolute; TOP: 88px" runat="server"
height="21px" width="136px">*Ønsket
kodeord<sup>2</sup></asp:label><asp:label id="Label14" style="Z-INDEX: 114; LEFT: 48px; POSITION: absolute; TOP: 120px" runat="server"
height="21px" width="128px">*Gentag
kodeord<sup>2</sup></asp:label><asp:label id="Label13" style="Z-INDEX: 113; LEFT: 48px; POSITION: absolute; TOP: 184px" runat="server"
height="21px" width="128px">*Email-adresse<sup>3</sup></asp:label><asp:label id="Label12" style="Z-INDEX: 112; LEFT: 48px; POSITION: absolute; TOP: 152px" runat="server"
height="21px" width="128px">*Rigtige
navn</asp:label><asp:label id="Label11" style="Z-INDEX: 111; LEFT: 48px; POSITION: absolute; TOP: 216px" runat="server"
height="21px" width="128px">*By</asp:label><asp:label id="Label10" style="Z-INDEX: 110; LEFT: 48px; POSITION: absolute; TOP: 248px" runat="server"
height="21px" width="128px">*Postnummer</asp:label><asp:label id="Label9" style="Z-INDEX: 109; LEFT: 48px; POSITION: absolute; TOP: 280px" runat="server"
height="21px" width="128px">Tilmeld
nyhedsbrev</asp:label><asp:label id="Label8" style="Z-INDEX: 108; LEFT: 48px; POSITION: absolute; TOP: 312px" runat="server"
height="21px" width="128px">*Skole/årgang<sup>4</sup></asp:label><asp:label id="Label7" style="Z-INDEX: 107; LEFT: 48px; POSITION: absolute; TOP: 344px" runat="server"
height="21px" width="136px">
<strong>Frivillige oplysinger</strong></asp:label><asp:label id="Label6" style="Z-INDEX: 106; LEFT: 48px; POSITION: absolute; TOP: 376px" runat="server"
height="16px" width="128px">Msn</asp:label><asp:label id="Label5" style="Z-INDEX: 105; LEFT: 48px; POSITION: absolute; TOP: 408px" runat="server"
height="21px" width="128px">Skype</asp:label><asp:label id="Label4" style="Z-INDEX: 104; LEFT: 48px; POSITION: absolute; TOP: 440px" runat="server"
height="21px" width="128px">Tlf.</asp:label><asp:label id="Label3" style="Z-INDEX: 103; LEFT: 48px; POSITION: absolute; TOP: 472px" runat="server"
height="21px" width="128px">Vis
Tlf.<sup>5</sup></asp:label><asp:label id="Label2" style="Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 504px" runat="server"
height="21px" width="128px">Beskrivelse</asp:label>
<asp:label id="Label16" style="Z-INDEX: 116; LEFT: 56px; POSITION: absolute; TOP: 630px" runat="server"
height="128px" width="561px"><sup>1</sup>Brugernavnet
skal være mellem 4 og 15 tegn. <br />Tilladte tegn: 0-9, a-z, A-Z, underscore(_) og bindestreg(-)<br />
<sup>2</sup>Det valgte kodeord skal være mellem 6 og 12 tegn langt. <br />Tilladte tegn: 0-9, a-z, A-Z, underscore(_) og bindestreg(-)<br />
<sup>3</sup>Sørg for at emailadressen er din egen da aktiveringskoden bliver sendt
til den emailadresse du angiver<br />
<sup>4</sup>Årgangen skal være det år hvor du bliver student<br />
<sup>5</sup>Telefonnummeret vil kun være synligt for de brugere der er oprettet i samme
klasse, altså dine nuværende/tidligere klassekammerater. </asp:label><asp:label id="Label17" style="Z-INDEX: 117; LEFT: 192px; POSITION: absolute; TOP: 8px" runat="server"
height="40px" width="336px" font-size="Large" font-bold="True">Opret
en bruger på besoffen.dk</asp:label><asp:textbox id="bruger" style="Z-INDEX: 118; LEFT: 200px; POSITION: absolute; TOP: 56px" runat="server"
Width="144px"></asp:textbox><asp:checkbox id="nyhedsbrev" style="Z-INDEX: 129; LEFT: 200px; POSITION: absolute; TOP: 280px"
runat="server" Width="104px" Height="24px" Checked="True"></asp:checkbox><asp:dropdownlist id="DropDownList1" style="Z-INDEX: 131; LEFT: 200px; POSITION: absolute; TOP: 312px"
runat="server" Width="144px" Height="24px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True" Runat="server"></asp:dropdownlist>
<asp:button id="Button1" OnClick="Button1_Click" style="Z-INDEX: 132; LEFT: 240px; POSITION: absolute; TOP: 584px" runat="server"
Width="56px" Text="Opret!"></asp:button><asp:dropdownlist id="DropDownList3" style="Z-INDEX: 133; LEFT: 360px; POSITION: absolute; TOP: 312px"
runat="server" Width="104px" Height="24px" Visible="False"></asp:dropdownlist><asp:requiredfieldvalidator id="RequiredFieldValidator1" style="Z-INDEX: 134; LEFT: 360px; POSITION: absolute; TOP: 56px"
runat="server" Width="16px" Height="24px" ControlToValidate="bruger" Display="Dynamic" ErrorMessage="Feltet brugernavn skal udfyldes">*</asp:requiredfieldvalidator><asp:requiredfieldvalidator id="RequiredFieldValidator2" style="Z-INDEX: 135; LEFT: 360px; POSITION: absolute; TOP: 88px"
runat="server" Width="16px" Height="24px" ControlToValidate="pass" Display="Dynamic" ErrorMessage="Du skal vælge et kodeord">*</asp:requiredfieldvalidator><asp:requiredfieldvalidator id="RequiredFieldValidator3" style="Z-INDEX: 136; LEFT: 360px; POSITION: absolute; TOP: 120px"
runat="server" Width="16px" Height="24px" ControlToValidate="pass2" Display="Dynamic" ErrorMessage="Du skal gentage din kode">*</asp:requiredfieldvalidator><asp:requiredfieldvalidator id="RequiredFieldValidator4" style="Z-INDEX: 137; LEFT: 360px; POSITION: absolute; TOP: 152px"
runat="server" Width="8px" Height="24px" ControlToValidate="name" Display="Dynamic" ErrorMessage="Du skal skrive dit navn">*</asp:requiredfieldvalidator><asp:requiredfieldvalidator id="RequiredFieldValidator5" style="Z-INDEX: 138; LEFT: 360px; POSITION: absolute; TOP: 184px"
runat="server" Width="16px" Height="16px" ControlToValidate="mail" Display="Dynamic" ErrorMessage="Du skal angive din email">*</asp:requiredfieldvalidator><asp:requiredfieldvalidator id="RequiredFieldValidator6" style="Z-INDEX: 139; LEFT: 360px; POSITION: absolute; TOP: 216px"
runat="server" Width="8px" Height="32px" ControlToValidate="city" Display="Dynamic" ErrorMessage="Du skal udfylde feltet by">*</asp:requiredfieldvalidator><asp:requiredfieldvalidator id="RequiredFieldValidator7" style="Z-INDEX: 140; LEFT: 256px; POSITION: absolute; TOP: 248px"
runat="server" Width="8px" Height="24px" ControlToValidate="post" Display="Dynamic" ErrorMessage="Du skal skrive dit postnummer">*</asp:requiredfieldvalidator><asp:comparevalidator id="CompareValidator1" style="Z-INDEX: 141; LEFT: 384px; POSITION: absolute; TOP: 120px"
runat="server" Width="8px" Height="24px" ControlToValidate="pass2" Display="Dynamic" ErrorMessage="De to kodeord er ikke ens" ControlToCompare="pass">*</asp:comparevalidator><asp:regularexpressionvalidator id="RegularExpressionValidator1" style="Z-INDEX: 142; LEFT: 272px; POSITION: absolute; TOP: 248px"
runat="server" Width="16px" Height="24px" ControlToValidate="post" Display="Dynamic" ErrorMessage="Postnummeret er ikke gyldigt" ValidationExpression="^\d{4}$">*</asp:regularexpressionvalidator><asp:regularexpressionvalidator id="RegularExpressionValidator2" style="Z-INDEX: 143; LEFT: 384px; POSITION: absolute; TOP: 184px"
runat="server" Width="16px" Height="16px" ControlToValidate="mail" Display="Dynamic" ErrorMessage="Email-adressen er ikke gyldig" ValidationExpression="^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$">*</asp:regularexpressionvalidator><asp:regularexpressionvalidator id="RegularExpressionValidator3" style="Z-INDEX: 144; LEFT: 384px; POSITION: absolute; TOP: 88px"
runat="server" Width="8px" Height="16px" ControlToValidate="pass" Display="Dynamic" ErrorMessage="Kodeordet overholder ikke de gældende krav" ValidationExpression="^[\w-]{6,12}$">*</asp:regularexpressionvalidator><asp:regularexpressionvalidator id="RegularExpressionValidator4" style="Z-INDEX: 145; LEFT: 384px; POSITION: absolute; TOP: 56px"
runat="server" Width="8px" Height="24px" ControlToValidate="bruger" Display="Dynamic" ErrorMessage="Brugernavnet overholder ikke de gældende regler" ValidationExpression="^[\w-]{4,15}$">*</asp:regularexpressionvalidator><asp:validationsummary id="ValidationSummary1" style="Z-INDEX: 146; LEFT: 408px; POSITION: absolute; TOP: 56px"
runat="server" Width="264px" Height="184px" DisplayMode="List" HeaderText="Der opstod fejl under oprettelsen:"></asp:validationsummary>
<asp:RegularExpressionValidator id="RegularExpressionValidator5" style="Z-INDEX: 147; LEFT: 352px; POSITION: absolute; TOP: 440px"
runat="server" Width="8px" Height="6px" ControlToValidate="tlf" ErrorMessage="Telefonnummeret skal være 8 tal"
ValidationExpression="^\d{8}$">*</asp:RegularExpressionValidator>
<asp:Label id="Label18" style="Z-INDEX: 148; LEFT: 360px; POSITION: absolute; TOP: 256px" runat="server"
Height="24px" Width="296px">Hej</asp:Label></form>
</body>
</HTML>
webform1.aspx.vb:
Public Class Opret
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents Label10 As System.Web.UI.WebControls.Label
Protected WithEvents Label11 As System.Web.UI.WebControls.Label
Protected WithEvents Label12 As System.Web.UI.WebControls.Label
Protected WithEvents Label13 As System.Web.UI.WebControls.Label
Protected WithEvents Label14 As System.Web.UI.WebControls.Label
Protected WithEvents Label15 As System.Web.UI.WebControls.Label
Protected WithEvents Label17 As System.Web.UI.WebControls.Label
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents DropDownList2 As System.Web.UI.WebControls.DropDownList
Protected WithEvents Label16 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents showtlf As System.Web.UI.WebControls.CheckBox
Protected WithEvents beskrivelse As System.Web.UI.WebControls.TextBox
Protected WithEvents tlf As System.Web.UI.WebControls.TextBox
Protected WithEvents skype As System.Web.UI.WebControls.TextBox
Protected WithEvents msn As System.Web.UI.WebControls.TextBox
Protected WithEvents post As System.Web.UI.WebControls.TextBox
Protected WithEvents city As System.Web.UI.WebControls.TextBox
Protected WithEvents mail As System.Web.UI.WebControls.TextBox
Protected WithEvents name As System.Web.UI.WebControls.TextBox
Protected WithEvents pass2 As System.Web.UI.WebControls.TextBox
Protected WithEvents pass As System.Web.UI.WebControls.TextBox
Protected WithEvents bruger As System.Web.UI.WebControls.TextBox
Protected WithEvents nyhedsbrev As System.Web.UI.WebControls.CheckBox
Protected WithEvents DropDownList3 As System.Web.UI.WebControls.DropDownList
Protected WithEvents RequiredFieldValidator1 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator2 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator3 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator4 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator5 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator6 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator7 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents CompareValidator1 As System.Web.UI.WebControls.CompareValidator
Protected WithEvents RegularExpressionValidator1 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents RegularExpressionValidator2 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents RegularExpressionValidator3 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents RegularExpressionValidator4 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents ValidationSummary1 As System.Web.UI.WebControls.ValidationSummary
Protected WithEvents RegularExpressionValidator5 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents Label18 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim conn As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("besoffen.mdb"))
Dim aAdapter As System.Data.OleDb.OleDbDataAdapter
Dim sql As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Hiv data ud til DropDownList1 med skoler
If Not Page.IsPostBack Then
CreateSkoler()
End If
End Sub
Public Sub CreateSkoler()
sql = "select id, skolenavn from skoler order by skolenavn"
conn.Open()
aAdapter = New System.Data.OleDb.OleDbDataAdapter(sql, conn)
Dim dsSkoler As System.Data.DataSet = New System.Data.DataSet
aAdapter.Fill(dsSkoler, "skoler")
DropDownList1.DataSource = dsSkoler
DropDownList1.DataTextField = "Skolenavn"
DropDownList1.DataValueField = "ID"
DropDownList1.DataBind()
DropDownList1.Items.Insert(0, "Vælg skole")
conn.Close()
End Sub
Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
'Hiv data ud til DropDownList3 med klasser på valgte skole
'DropDownList1.selecteditem.value til at hente id for skolen
If DropDownList1.SelectedIndex <> 0 Then
DropDownList3.Visible = True
sql = "select klasse, klassenavn from klasser where SkoleID=" & DropDownList1.SelectedItem.Value & " order by klasse"
conn.Open()
aAdapter = New System.Data.OleDb.OleDbDataAdapter(sql, conn)
Dim dsKlasser As System.Data.DataSet = New System.Data.DataSet
aAdapter.Fill(dsKlasser, "klasser")
DropDownList3.DataSource = dsKlasser
DropDownList3.DataTextField = "klassenavn"
DropDownList3.DataValueField = "klasse"
DropDownList3.DataBind()
DropDownList3.Items.Insert(0, "Vælg Klasse")
conn.Close()
Else
DropDownList3.Visible = False
End If
End Sub
Function Send_Mail(ByVal navn As String, ByVal email As String, ByVal subject As String, ByVal body As String, ByVal strKey As String)
Dim mm As New System.Net.Mail.MailMessage
mm.To = email
mm.From = "support@besoffen.dk"
mm.Subject = subject
mm.Body = body
Dim smtp As System.Net.Mail.Smtpclient
smtp.Send(mm)
smtp.OnSendCompleted(Registrer_Bruger(strKey))
End Function
Function ConvertDate(ByVal dtmDate, ByVal intFormat)
Dim OutDate, OutTime, strOut As String
OutDate = DatePart("yyyy", dtmDate) & "-" & DatePart("m", dtmDate) & "-" & DatePart("d", dtmDate)
OutTime = DatePart("h", dtmDate) & ":" & DatePart("n", dtmDate) & ":" & DatePart("s", dtmDate)
If intFormat = 0 Then
strOut = OutDate & " " & OutTime
ElseIf intFormat = 1 Then
strOut = OutDate
End If
ConvertDate = strOut
End Function
Private Sub Registrer_Bruger(ByVal strKey As String)
Dim dbcomm As OleDb.OleDbCommand
Dim strKrypPass As String
Dim byteKrypPass
Dim utf8 As New System.Text.UTF8Encoding
Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
byteKrypPass = md5.ComputeHash(utf8.GetBytes(pass.Text))
strKrypPass = utf8.GetString(byteKrypPass)
sql = "insert into brugere (username,password,oprettet,nyhedsbrev,city,postnummer,navn,mail,aktiveret,tlf,showtlf,msn,skype,beskrivelse,klasse,skole,lvl)"
sql = sql & " values('" & bruger.Text & "', '" & strKrypPass & "', #" & ConvertDate(Now(), 0) & "#," & nyhedsbrev.Checked & ",'" & city.Text & "'," & post.Text & ",'" & name.Text & "','" & mail.Text & "','" & strKey & "','" & tlf.Text & "'," & showtlf.Checked & ",'" & msn.Text & "','" & skype.Text & "','" & Replace(beskrivelse.Text, "'", "''") & "','" & DropDownList3.SelectedItem.Value & "'," & DropDownList1.SelectedItem.Value & ",2)"
'dbcomm = New OleDb.OleDbCommand(sql, conn)
'dbcomm.ExecuteNonQuery()
Label18.Text = sql
End Sub
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Page.IsValid Then
'Indsæt brugere i databasen samtidig med at email med key osv. sendes til den angivne mailadresse
Dim strbody, strsubject As String
Dim strKey As String = RandomKey(10)
strsubject = "Aktivering af bruger hos Besoffen.dk"
strbody = "Hej " & name.Text & "." & vbCrLf & "<br>Velkommen til Besoffen.dk's community, vi håber du vil deltage aktivt på siden så kontakten mellem nuværende/tidligere klassekammerater kan vedligeholdes."
strbody = strbody & "" & vbCrLf & "<br>Du skal aktivere din bruger før du kan logge ind, dette gøres på:" & vbCrLf
strbody = strbody & "<br><a href='
http://www.besoffen.dk/opret.asp?mode=aktivering&key=" & strKey & "&bruger=" & bruger.Text & "'>"
strbody = strbody & "
http://www.besoffen.dk/opret.asp?mode=aktivering&key=" & strKey & "&bruger=" & bruger.Text
strbody = strbody & "</a>.Herefter skal en administrator godkende dig."
strbody = strbody & "<br><br>Dit brugernavn er: " & bruger.Text & "<br>Password er: " & pass.Text & "<br>Husk disse oplysninger!<br>"
strbody = strbody & "" & vbCrLf & "<br>Brugeren skal aktiveres inden 24 timer, ellers vil brugeren blive slettet automatisk." & vbCrLf & "<br>"
strbody = strbody & "" & vbCrLf & "<br>Vi håber du vil finde dig godt til rette og nyde siden lige så meget som vi har nydt at lave den."
strbody = strbody & "" & vbCrLf & "<br>M.v.h. " & vbCrLf & "<br>Team-Besoffen.dk<br>Casper Schmidt & Thomas Schwartz<br>Programmør & Designer"
'Send_Mail(name.Text, mail.Text, strsubject, strbody, strKey)
Registrer_Bruger(strKey)
End If
End Sub
Function RandomKey(ByVal iantal)
Dim strKey, strLetter As String
Dim n, ital As Integer
Dim strArray
strKey = ""
n = 0
ital = 0
strLetter = ""
strArray = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"
strArray = Split(strArray, ",")
Randomize()
For n = 0 To (iantal) - 1
Do
ital = Int(Rnd() * (35 + 5))
If (ital >= 1) And (ital <= 35) Then
strLetter = strArray(ital)
Exit Do
End If
Loop
strKey = strKey & strLetter
strLetter = ""
Next
RandomKey = strKey
End Function
End Class
Kalle