网站首页 > 文章中心 > 其它

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

作者:小编 更新时间:2023-10-24 11:16:30 浏览量:268人看过

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

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

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

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

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

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

代码如下:board.aspx

HTML

HEAD

title/title

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"

Columns

/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

#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 Region

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

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

If Session("stu_id") = "" Then

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

check()

Else

If Not IsPostBack Then

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

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()

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

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

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

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

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

End If

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

End While

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

'////////////////////////取出数据,填充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()

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

Sub check()

Dim comm As New SqlCommand(mysql, conn)

'/////////////////////填充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

mycheck.Items(i).Selected = False

Next

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

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

If mycheck.Items(i).Selected Then

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

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

comm.ExecuteNonQuery()

Response.Redirect("boaman.aspx")

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

End Class

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

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

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

Hand类的代码:

Public MustInherit Class Hand

Protected gp As GraphicsPath = New GraphicsPath()

Protected gpBase As GraphicsPath = Nothing

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

Public Sub New(ByVal theForm As Form1)

MustOverride Sub Transform(ByVal d As DateTime)

'绘制指针路径

Overridable Sub Draw(ByVal g As Graphics)

g.DrawPath(aPen, gp)

g.FillPath(Brushes.Black, gp)

aPen.Dispose()

'使用矩阵实现路径(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)

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

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

Public Class MinuteHand

Inherits Hand

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

Public Sub New(ByVal myForm As Form1)

MyBase.New(myForm)

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

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

Public Overrides Sub Transform(ByVal d As DateTime)

Rotate(angle)

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

Public Sub Draw(ByVal g As Graphics)

DrawClockFace(g)

DrawImage(g)

DrawNumbers(g)

DrawPin(g)

下面是ClockFace类的属性:

Private ClockRectangle As Rectangle

Private midPoint As Point

Private ClockImage As Bitmap

DrawClockFace方法用来画时钟表面:

Private Sub DrawClockFace(ByVal g As Graphics)

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

Private Sub DrawImage(ByVal g As Graphics)

Dim nWidth As Integer = ClockImage.Width

Dim nHeight As Integer = ClockImage.Height

g.DrawImage(ClockImage, destRect)

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

Private Sub DrawNumbers(ByVal g As Graphics)

Dim count As Integer = 1

Dim a As Double

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

count += 1

最后是窗体文件(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)

'计时器事件

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分.

? ? 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

? ? ? ? dingcun = fuli_small

? ? ? ? fuli_big = fuli_big + fuli_small

? ? Next

? ? 'fuli_big = fuli_small

? ? TextBox1.Text = DATAstring

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

求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 }

ON SEQUENCE sequencename [, ...]

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

ON DATABASE dbname [, ...]

GRANT { EXECUTE | ALL [ PRIVILEGES ] }

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

GRANT { USAGE | ALL [ PRIVILEGES ] }

ON LANGUAGE langname [, ...]

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

ON SCHEMA schemaname [, ...]

GRANT { CREATE | ALL [ PRIVILEGES ] }

ON TABLESPACE tablespacename [, ...]

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

希望对你有帮助

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

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

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

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

dim dt As New DataTable

dim cmd As New SqlCommand

With cmd

.Parameters.Add(New SqlClient.SqlParameter("@UserName", "=你输入的用户名TextBox1.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有意思的源码的信息相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章