189 8069 5689

关于vb.net有意思的源码的信息

100分求一个用VB.net做的简单网页的代码,谢谢!!!

用vb.net做的校友录……(附所有源代码)

成都创新互联是网站建设专家,致力于互联网品牌建设与网络营销,专业领域包括成都网站设计、成都网站制作、外贸网站建设、电商网站制作开发、微信平台小程序开发、微信营销、系统平台开发,与其他网站设计及系统开发公司不同,我们的整合解决方案结合了恒基网络品牌建设经验和互联网整合营销的理念,并将策略和执行紧密结合,且不断评估并优化我们的方案,为客户提供全方位的互联网品牌整合方案!

来源:不详 作者 佚名 点击数:31 录入时间:07-12-17 15:21:39

想必大家都上过校友录吧,里面的功能虽然不是很强大,但是为我们这些毕业之后各奔西东的学子来说,到真是提供了一个好的聚集点,下面是我用vb.net做的校友录,当然也不能说是校友录了,只能说是我们班的学友录了:)不过只要你掌握了这种编程思想,校友录就不在话下了。这里我将重点谈一下关于管理员权限赋予。

以前有这个想法的时候,难就难在管理员身份的赋予上,开始想如果一般用户在被提升为管理员之后,我可以把他的信息转到另外一个表中,以后登陆的时候先检查manage表中是否有他就行了,这种办法我已经实现了,是不是有些笨……可是正在我要正式开工的时候,一个想法突然冒了出来,是什么呢?呵呵,就是在数据库中再增加一个字段了如果是第一次注册就让这个字段item(int)的值为0,要是被提升之后就update为1,班级创始人呢?当然了,在他申请时付给他一个班级id,然后先判断班级id为这个已经注册的人信息条数是否为0,如果是,那么就付给他item=2好了。下面的代码中,我没有实现这个功能,因为我做的是班友录的,当然了,我就是管理员喽:)

在这里,我使用的是checkboxlist(两个),一个用来转换数据(visibe=fause),一个用来显示数据,还有一个checkbox用来写全部选中的事件。当然了还有两个按钮事件,一个是用来提升为管理员的,一个是用来降级为一般用户的,这两个按钮在判断为一般用户时

enable都是为fause的,只有当判断登录为管理员时才为true。当然了,如果你是班级创始人,是不可能被降级的:)

这里用来显示信息的我用的是一个datagrid,当判断为非管理员时,删除栏的visible将为fause,为管理员的时候,才为true,也就是说只有管理员才可以删除信息。而不是注册的用户是不能发言的所有的按钮控件的enable将都为fause。

代码如下:board.aspx

%@ Page Language="vb" AutoEventWireup="false" Codebehind="boaman.aspx.vb" Inherits="_99re1.boaman"%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"

HTML

HEAD

title/title

meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR"

meta content="Visual Basic 7.0" name="CODE_LANGUAGE"

meta content="javascript" name="vs_defaultClientScript"

meta content="" name="vs_targetSchema"

/HEAD

body background="image/bg.gif" MS_POSITIONING="GridLayout"

form id="Form1" method="post" runat="server"

asp:checkbox id="yourcheck" style="Z-INDEX: 101; LEFT: 84px; POSITION: absolute; TOP: 71px" runat="server" Text="全部选中" AutoPostBack="True" ForeColor="SaddleBrown" Font-Bold="True"/asp:checkbox

asp:button id="Button1" style="Z-INDEX: 102; LEFT: 34px; POSITION: absolute; TOP: 43px" runat="server" Text="提升为管理员" Height="20px" Width="100px" BackColor="Gainsboro" BorderColor="Lavender" BorderWidth="2px" BorderStyle="Outset"/asp:button

asp:button id="Button2" style="Z-INDEX: 103; LEFT: 142px; POSITION: absolute; TOP: 43px" runat="server" Text="降级为一般用户" Height="20px" Width="100px" BackColor="Gainsboro" BorderColor="Lavender" BorderWidth="2px" BorderStyle="Outset"/asp:button

asp:checkboxlist id="CheckBoxList1" style="Z-INDEX: 104; LEFT: 14px; POSITION: absolute; TOP: 10px" runat="server" Visible="False"/asp:checkboxlist

asp:checkboxlist id="mycheck" style="Z-INDEX: 105; LEFT: 98px; POSITION: absolute; TOP: 99px" runat="server" ForeColor="Navy" Font-Size="X-Small"/asp:checkboxlist

asp:label id="Label1" style="Z-INDEX: 106; LEFT: 82px; POSITION: absolute; TOP: 14px" runat="server" ForeColor="Red" Font-Names="方正姚体"(已注册用户)/asp:label

asp:image id="Image1" style="Z-INDEX: 107; LEFT: 260px; POSITION: absolute; TOP: 180px" runat="server" Height="124px" Width="221px" ImageUrl="image/99re1-1.gif"/asp:image

asp:datagrid id="DataGrid1" style="Z-INDEX: 108; LEFT: 250px; POSITION: absolute; TOP: 83px" runat="server" Height="113px" Width="461px" BorderColor="#ffcc66" AutoGenerateColumns="False" HeaderStyle-Font-Size="9" HeaderStyle-HorizontalAlign="Center" HeaderStyle-ForeColor="red" HeaderStyle-Font-Bold="True"

Columns

asp:HyperLinkColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="24" ItemStyle-Font-Size="9" DataNavigateUrlField="stu_id" DataNavigateUrlFormatString="querry.aspx?stu_id={0}" DataTextField="stu_id" HeaderText="学号"/asp:HyperLinkColumn

asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="100" ItemStyle-Font-Size="9" DataField="tel" HeaderText="电话"/asp:BoundColumn

asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="80" ItemStyle-Font-Size="9" DataField="oicq" HeaderText="OICQ"/asp:BoundColumn

asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="140" ItemStyle-Font-Size="9" DataField="email" HeaderText="E-mail"/asp:BoundColumn

asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="60" ItemStyle-Font-Size="9" DataField="point" HeaderText="登录次数"/asp:BoundColumn

/Columns

/asp:datagrid

/form

/body

/HTML

下面是codebehind中的内容:boaman.asp.vb

Imports System.Data

Imports System.Data.SqlClient

Public Class boaman

Inherits System.Web.UI.Page

Protected WithEvents yourcheck As System.Web.UI.WebControls.CheckBox

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents CheckBoxList1 As System.Web.UI.WebControls.CheckBoxList

Protected WithEvents mycheck As System.Web.UI.WebControls.CheckBoxList

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents Image1 As System.Web.UI.WebControls.Image

Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

Protected WithEvents Button2 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()

End Sub

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 SqlConnection = New SqlConnection("server=lixinri;uid=sa;pwd=;database=99re1")

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'////////////////////判断是否为过客

If Session("stu_id") = "" Then

Button1.Enabled = False : Button2.Enabled = False

'////////////////////调用check()事件

check()

Else

If Not IsPostBack Then

Dim sql As String = "select * from pwd where stu_id=@stu_id"

Dim comm As SqlCommand = New SqlCommand(sql, conn)

comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))

comm.Parameters("@stu_id").Value = Session("stu_id")

Dim dr As SqlDataReader

conn.Open()

dr = comm.ExecuteReader

While dr.Read

If dr.Item("term") = "0" Then

'///////////////////判断是否为一般用户

dr.Close()

Button1.Enabled = False : Button2.Enabled = False

Dim sql_1 As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"

Dim cmd As New SqlCommand(sql_1, conn)

dr = cmd.ExecuteReader

While dr.Read

If dr.Item("term") = "1" Then

mycheck.Items.Add("u" dr.Item("name") "/u" "font color=darkorange(管理员)/font")

ElseIf dr.Item("term") = "2" Then

mycheck.Items.Add("u" dr.Item("name") "/u" "font color=red(班级创始人)font")

Else

mycheck.Items.Add("u" dr.Item("name") "/u")

End If

CheckBoxList1.Items.Add(dr.Item("stu_id"))

End While

Else

'////////////////////判断是否为管理员

dr.Close()

Button1.Enabled = True : Button2.Enabled = True

Dim sql_1 As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"

Dim cmd As New SqlCommand(sql_1, conn)

dr = cmd.ExecuteReader

While dr.Read

If dr.Item("term") = "1" Then

mycheck.Items.Add("u" dr.Item("name") "/u" "font color=darkorange(管理员)/font")

ElseIf dr.Item("term") = "2" Then

mycheck.Items.Add("u" dr.Item("name") "/u" "font color=red(班级创始人)font")

Else

mycheck.Items.Add("u" dr.Item("name") "/u")

End If

CheckBoxList1.Items.Add(dr.Item("stu_id"))

End While

End If

End While

dr.Close()

'////////////////////////取出数据,填充dataset

Dim mysql As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"

comm = New SqlCommand(mysql, conn)

Dim mycomm As SqlDataAdapter = New SqlDataAdapter(mysql, conn)

Dim ds As DataSet = New DataSet()

mycomm.Fill(ds, "base")

DataGrid1.DataSource = ds.Tables("base").DefaultView

DataGrid1.DataBind()

End If

End If

End Sub

'///////////////////////书写check()事件

Sub check()

If Not IsPostBack Then

Dim mysql As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"

Dim comm As New SqlCommand(mysql, conn)

Dim dr As SqlDataReader

conn.Open()

dr = comm.ExecuteReader

While dr.Read

If dr.Item("term") = "1" Then

mycheck.Items.Add("u" dr.Item("name") "/u" "font color=darkorange(管理员)/font")

ElseIf dr.Item("term") = "2" Then

mycheck.Items.Add("u" dr.Item("name") "/u" "font color=red(班级创始人)font")

Else

mycheck.Items.Add("u" dr.Item("name") "/u")

End If

CheckBoxList1.Items.Add(dr.Item("stu_id"))

End While

dr.Close()

Dim mycomm As SqlDataAdapter = New SqlDataAdapter(mysql, conn)

Dim ds As DataSet = New DataSet()

mycomm.Fill(ds, "base")

DataGrid1.DataSource = ds.Tables("base").DefaultView

DataGrid1.DataBind()

End If

End Sub

'/////////////////////填充yourcheck

Private Sub yourcheck_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles yourcheck.CheckedChanged

Dim i As Integer

For i = 0 To mycheck.Items.Count - 1

If yourcheck.Checked Then

mycheck.Items(i).Selected = True

Else

mycheck.Items(i).Selected = False

End If

Next

End Sub

'///////////////////////提升一般用户为管理员

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

conn.Open()

Dim i As Integer

For i = 0 To mycheck.Items.Count - 1

If mycheck.Items(i).Selected Then

Dim sql_1 As String = "update pwd set term=1 where stu_id=@stu_id and term=0"

Dim comm As SqlCommand = New SqlCommand(sql_1, conn)

comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))

comm.Parameters("@stu_id").Value = CheckBoxList1.Items(i).Text

comm.ExecuteNonQuery()

End If

Next

Response.Redirect("boaman.aspx")

End Sub

'///////////////////////降级管理员为一般用户

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

conn.Open()

Dim i As Integer

For i = 0 To mycheck.Items.Count - 1

If mycheck.Items(i).Selected Then

Dim sql_1 As String = "update pwd set term=0 where stu_id=@stu_id and term=1"

Dim comm As SqlCommand = New SqlCommand(sql_1, conn)

comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))

comm.Parameters("@stu_id").Value = CheckBoxList1.Items(i).Text

comm.ExecuteNonQuery()

End If

Next

Response.Redirect("boaman.aspx")

End Sub

End Class

当然了,这里面还有好多不足的地方,恳求高手批评指正。

校友录还有一些其它的功能就很简单了,这里就不再探讨了。

vb.net开发简单的时钟程序??高手救救我!

Hand类的代码:

Public MustInherit Class Hand

Protected gp As GraphicsPath = New GraphicsPath()

Protected gpBase As GraphicsPath = Nothing

Protected midX As Integer = 150 ‘默认的窗体

Protected midY As Integer = 150 ‘中心位置

‘构造器,得到窗体中心位置

Public Sub New(ByVal theForm As Form1)

midX = (theForm.ClientRectangle.Left + theForm.ClientRectangle.Right) / 2

midY = (theForm.ClientRectangle.Top + theForm.ClientRectangle.Bottom) / 2

End Sub

MustOverride Sub Transform(ByVal d As DateTime)

‘绘制指针路径

Overridable Sub Draw(ByVal g As Graphics)

Dim aPen As Pen = New Pen(Brushes.Black, 4F)

g.DrawPath(aPen, gp)

g.FillPath(Brushes.Black, gp)

aPen.Dispose()

End Sub

‘使用矩阵实现路径(gp)的旋转

Public Sub Rotate(ByVal angle As Double)

gp = CType(gpBase.Clone(), GraphicsPath)

Dim mTransform As Matrix = New Matrix()

mTransform.RotateAt(CType(angle,Single),NewPointF(midX,midY))

gp.Transform(mTransform)

End Sub

End Class

为了节省篇幅,上面的代码省略了引入命名空间的语句。

下面是分针(MinuteHand)类的定义:

Public Class MinuteHand

Inherits Hand

‘构造器,生成绘制分针的路径(gp)

Public Sub New(ByVal myForm As Form1)

MyBase.New(myForm)

gp.AddLine(midX, midY, midX, 45)

gp.AddLine(midX, 45, midX - 3, 50)

gp.AddLine(midX - 3, 50, midX + 3, 50)

gp.AddLine(midX + 3, 50, midX, 45)

gpBase = CType(gp.Clone(), GraphicsPath)

End Sub

‘Transform方法取得系统当前时间,并旋转时钟指针。

Public Overrides Sub Transform(ByVal d As DateTime)

Dim minuteTime As Double = (CDbl(d.Minute) + CDbl(d.Second / 60))

Dim angle As Double = (CDbl(minuteTime) / 60) * 360

Rotate(angle)

End Sub

End Class

对所有的指针旋转的方法都是相同的,因此在基类中实现。由于时针和秒针的实现与分针相似,所不同者,只在于构造器中绘制的指针路径不同和Transform方法中转动的角度不同,在这里就不在赘述了。

另外还需要提一下的是画时钟表面的代码,时钟表面用ClockFace类来实现。这个类首先画一个圆代表时钟,然后画上米老鼠的图案,最后在相应的位置画上数字1~12代表12个小时。

Public Sub Draw(ByVal g As Graphics)

DrawClockFace(g)

DrawImage(g)

DrawNumbers(g)

DrawPin(g)

End Sub

下面是ClockFace类的属性:

Private ClockRectangle As Rectangle

Private ClockFont As Font = New Font("Arial", 12)

Private midPoint As Point

Private ClockImage As Bitmap

Private Const IMAGEX As Integer = 50

Private Const IMAGEY As Integer = 50

DrawClockFace方法用来画时钟表面:

Private Sub DrawClockFace(ByVal g As Graphics)

g.FillEllipse(Brushes.White, ClockRectangle.Left + 10, ClockRectangle.Top + 10, ClockRectangle.Width - 20, ClockRectangle.Height - 20)

g.DrawEllipse(Pens.Black, ClockRectangle.Left + 10, ClockRectangle.Top + 10, ClockRectangle.Width - 20, ClockRectangle.Height - 20)

End Sub

然后用Graphics对象的DrawImage方法画出米老鼠的图片:

Private Sub DrawImage(ByVal g As Graphics)

Dim nWidth As Integer = ClockImage.Width

Dim nHeight As Integer = ClockImage.Height

Dim destRect As Rectangle = New Rectangle(midPoint.X - IMAGEX / 2, midPoint.Y - IMAGEY / 2, IMAGEX, IMAGEY)

g.DrawImage(ClockImage, destRect)

End Sub

数字在时钟上的位置是用sin和cos函数计算的:

Private Sub DrawNumbers(ByVal g As Graphics)

Dim count As Integer = 1

Dim a As Double

For a = 0 To 2 * Math.PI Step 2 * Math.PI / 12

Dim x As Double = (ClockRectangle.Width - 70) / 2 * Math.Cos(a - Math.PI / 3) + (ClockRectangle.Width - 70) / 2 + 25

Dim y As Double = (ClockRectangle.Width - 70) / 2 * Math.Sin(a - Math.PI / 3) + (ClockRectangle.Width - 70) / 2 + 20

g.DrawString(Convert.ToString(count), ClockFont, Brushes.Black, CType(x, Single), CType(y, Single), New StringFormat())

count += 1

Next

End Sub

最后是窗体文件(Form1.vb):

Public Class Form1

Inherits System.Windows.Forms.Form

Private MyMinuteHand As MinuteHand

Private MyHourHand As HourHand

Private MySecondHand As SecondHand

Private TheClockFace As ClockFace

Private FirstTick As Boolean = False

‘在窗体的OnPaint事件中取得Graphics对象

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

If (FirstTick = False) Then Exit Sub

Dim g As Graphics = e.Graphics

TheClockFace.Draw(g)

MyHourHand.Draw(g)

MyMinuteHand.Draw(g)

MySecondHand.Draw(g)

TheClockFace.DrawPin(g)

End Sub

‘计时器事件

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

MySecondHand.Transform(DateTime.Now)

MyHourHand.Transform(DateTime.Now)

MyMinuteHand.Transform(DateTime.Now)

FirstTick = True

Invalidate()

求vb.net的源代码,最好说明其解决问题,越多越好,满意加50分。

下面这段代码,是我用来计算每个月存500元进银行,连续30年,最后连本带利能有多少钱。这里面涉及复利计算。界面中右边的文本框用来输出每一次计算的结果。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  Dim nianxian As Integer '年限变量

  Dim dingcun As Integer '定存变量

  Dim fuli_big As Long '大复利

  Dim fuli_small As Long '小复利

  Dim i As Integer '循环变量

  Dim DATAstring As String '数据字符串

  nianxian = Val(年限_TextBox.Text)

  dingcun = Val(定存_TextBox.Text)

  DATAstring = ""

  For i = 1 To nianxian

      fuli_small = dingcun * (1 + 0.1875)

      dingcun = fuli_small

      fuli_big = fuli_big + fuli_small

      DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_big) + Chr(13) + Chr(10)

      'DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_small) + Chr(13) + Chr(10)

  Next

  'fuli_big = fuli_small

  TextBox1.Text = DATAstring

  结果_TextBox.Text = Str(fuli_big) + "元"

End Sub

求VB.NET网站权限的源代码或实例

GRANT { { SELECT | INSERT | UPDATE | DELETE | REFERENCES | TRIGGER }

[,...] | ALL [ PRIVILEGES ] }

ON [ TABLE ] tablename [, ...]

TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]

GRANT { { USAGE | SELECT | UPDATE }

[,...] | ALL [ PRIVILEGES ] }

ON SEQUENCE sequencename [, ...]

TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]

GRANT { { CREATE | CONNECT | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] }

ON DATABASE dbname [, ...]

TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]

GRANT { EXECUTE | ALL [ PRIVILEGES ] }

ON FUNCTION funcname ( [ [ argmode ] [ argname ] argtype [, ...] ] ) [, ...]

TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]

GRANT { USAGE | ALL [ PRIVILEGES ] }

ON LANGUAGE langname [, ...]

TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]

GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }

ON SCHEMA schemaname [, ...]

TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]

GRANT { CREATE | ALL [ PRIVILEGES ] }

ON TABLESPACE tablespacename [, ...]

TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]

GRANT role [, ...] TO username [, ...] [ WITH ADMIN OPTION ]

希望对你有帮助

VB.NET获取需要登录后的源码

很简单的。这个最基本的了。

就是从数据库表中 找出一个记录,名称和密码都和你输入的一样的记录,就表示登陆成功。

简单的思路:(密码也没有加密等)

dim dt As New DataTable

dim cmd As New SqlCommand

With cmd

.CommandText = "Select * From Users Where UserName=@UserName and UserPwd=@UserPwd"

.Parameters.Add(New SqlClient.SqlParameter("@UserName", "=你输入的用户名TextBox1.Text"))

.Parameters.Add(New SqlClient.SqlParameter("@strColorNo", "=你输入的密码TextBox2.Text"))

End With

dt =SqlHelper.GetDatatable(cmd)

if dt.rows.count0 then

msgbox "ok"

else

msgbox "error"

end if

VB.Net猜字小游戏源代码。

这并不难,但程序肯定很长,其实,只要你已经学会了VB,这个问题并不难,但只是懒惰。,你应该自己编的,遇到问题,我们要问,请不要问。

锤子,图片显示和隐藏的Visible属性设置为指示的出现和消失的仓鼠,您可以使用自定义鼠标。


网页标题:关于vb.net有意思的源码的信息
网页路径:http://cdxtjz.cn/article/hesegi.html

其他资讯