189 8069 5689

vb.net实例大全的简单介绍

关于VB.NET进度条的实例

这是我自己写的一个进度条控件,如图:

创新互联专注于中大型企业的成都网站设计、成都网站建设和网站改版、网站营销服务,追求商业策划与数据分析、创意艺术与技术开发的融合,累计客户数千家,服务满意度达97%。帮助广大客户顺利对接上互联网浪潮,准确优选出符合自己需要的互联网运用,我们将一直专注成都品牌网站建设和互联网程序开发,在前进的路上,与客户一起成长!

边框粗细和边框颜色以及进度条颜色都可以调。

进度条大小你可以自己拉伸。

同时,进度条还提供了丰富的动画效果(如边框闪烁效果【可关闭】,进度条滑动效果等。)

将边框粗细调为0即可实现无边框(同时边框闪烁效果(见“Flash”属性)也将关闭!)

进度值(见“ProgressValue”属性)类型为Single(单精度浮点数)

将我提供的DLL文件拖到工具箱即可安装

只能用于Windows窗体应用程序!

目标平台:.Net Framework 3.5

属性说明:

1.BorderColor 用于调整边框颜色

2.BorderWidth 用于调整边框粗细

3.Flash 用于开启、关闭边框闪烁效果

4.ProgressValue 用于设置、查看进度值

5.ForeColor 用于设置进度条颜色

6.BackColor 用于设置控件背景色

附件如果丢失,请私信。

VB.NET设置屏幕分辨率、颜色位数、刷新率 实例代码

这篇文章介绍了VB.NET设置屏幕分辨率、颜色位数、刷新率

实例代码,有需要的朋友可以参考一下

复制代码

代码如下:

Private

Declare

Function

GetDeviceCaps

Lib

"gdi32"

(ByVal

hdc

As

Long,

ByVal

nIndex

As

Long)

As

Long

Private

Declare

Function

ChangeDisplaySettings

Lib

"user32"

Alias

"ChangeDisplaySettingsA"

(lpDevMode

As

Any,

ByVal

dwflags

As

Long)

As

Long

Private

Const

CCDEVICENAME

As

Long

=

32

Private

Const

CCFORMNAME

As

Long

=

32

Private

Const

DM_BITSPERPEL

As

Long

=

H40000

Private

Const

DM_PELSWIDTH

As

Long

=

H80000

Private

Const

DM_PELSHEIGHT

As

Long

=

H100000

Private

Const

DM_DISPLAYFLAGS

As

Long

=

H200000

Private

Const

DM_DISPLAYFREQUENCY

=

H400000

Private

Const

CDS_FORCE

As

Long

=

H80000000

Private

Const

BITSPIXEL

As

Long

=

12

Private

Const

HORZRES

As

Long

=

8

Private

Const

VERTRES

As

Long

=

10

Private

Const

VREFRESH

=

116

Private

Type

DEVMODE

dmDeviceName

As

String

*

CCDEVICENAME

dmSpecVersion

As

Integer

dmDriverVersion

As

Integer

dmSize

As

Integer

dmDriverExtra

As

Integer

dmFields

As

Long

dmOrientation

As

Integer

dmPaperSize

As

Integer

dmPaperLength

As

Integer

dmPaperWidth

As

Integer

dmScale

As

Integer

dmCopies

As

Integer

dmDefaultSource

As

Integer

dmPrintQuality

As

Integer

dmColor

As

Integer

dmDuplex

As

Integer

dmYResolution

As

Integer

dmTTOption

As

Integer

dmCollate

As

Integer

dmFormName

As

String

*

CCFORMNAME

dmUnusedPadding

As

Integer

dmBitsPerPel

As

Integer

dmPelsWidth

As

Long

dmPelsHeight

As

Long

dmDisplayFlags

As

Long

dmDisplayFrequency

As

Long

End

Type

Private

Sub

cmdChangeDesktopMode_Click()

Dim

DM

As

DEVMODE

With

DM

.dmPelsWidth

=

CInt(txtNewWidth.Text)

.dmPelsHeight

=

CInt(txtNewHeight.Text)

.dmBitsPerPel

=

CInt(txtNewColor.Text)

.dmDisplayFrequency

=

CInt(txtNewFreq.Text)

.dmFields

=

DM_PELSWIDTH

Or

DM_PELSHEIGHT

Or

DM_BITSPERPEL

Or

DM_DISPLAYFREQUENCY

.dmSize

=

LenB(DM)

End

With

If

ChangeDisplaySettings(DM,

CDS_FORCE)

Then

MsgBox

"错误!不支持此模式!"

End

If

End

Sub

Private

Sub

Form_Load()

txtOldWidth.Text

=

GetDeviceCaps(Me.hdc,

HORZRES)

txtOldHeight.Text

=

GetDeviceCaps(Me.hdc,

VERTRES)

txtOldColor.Text

=

GetDeviceCaps(Me.hdc,

BITSPIXEL)

txtOldFreq.Text

=

GetDeviceCaps(Me.hdc,

VREFRESH)

End

Sub

求vb.net句柄实例,实现操作其他程序窗口。如我给的例子

Imports System.Text

Imports System.Runtime.InteropServices

Public Class Form1

' 相关API函数声明,注释掉的这里没用到,但是也比较常用吧,这些函数的功能都能搜到。

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr

Private Delegate Function EnumChildProc(ByVal hWnd As IntPtr, ByVal lParam As Integer) As Boolean

Private Declare Function EnumChildWindows Lib "user32.dll" (ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumChildProc, ByVal lParam As Integer) As Boolean

Private Declare Auto Function SendMessage Lib "User32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer

'Private Declare Function CheckDlgButton Lib "user32" Alias "CheckDLGButtonA" (ByVal hDlg As IntPtr, ByVal nIDButton As IntPtr, ByVal wCheck As Integer) As Integer

Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As IntPtr, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer

'Private Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As IntPtr, ByVal lpdwProcessId As Long) As Integer

Private Declare Auto Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLength" (ByVal hwnd As IntPtr) As Integer

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer

' 相关消息定义,也有没用到的

Const WM_SETTEXT = HC

Const WM_GETTEXT = HD

'Const WM_SETFOCUS = H7

'Const WM_KILLFOCUS = H8

'Const WM_CLOSE = H10

'Const WM_SYSCOMMAND = H112

'Const SC_CLOSE = HF060

'Const SC_MINIMIZE = HF020

Const BM_GETCHECK = HF0

Const BM_SETCHECK = HF1

Const BM_GETSTATE = HF2

Const BM_SETSTATE = HF3

Const BM_SETSTYLE = HF4

Const BM_CLICK = HF5

'Const BM_GETIMAGE = HF6

'Const BM_SETIMAGE = HF7

Const BST_UNCHECKED = O0

Const BST_CHECKED = O1

Const BST_INDETERMINATE = O2

' 储存窗口句柄

Dim WindowHandle As IntPtr

' 储存两个(或者多个)编辑框句柄

Dim EditHandle As New List(Of IntPtr)

Dim EditWindowsText As List(Of String)

' 储存复选框句柄

Dim CheckHandle As IntPtr = 0

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

Button1_Click(sender, e)

End Sub

' EnumChildWindows 回调函数,该函数名作为API函数EnumChildWindows 的一个参数

' 该函数实现了枚举各个子窗口,找出编辑框属性的功能

Public Function EnumChildProcC(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean

Dim dwWindowClass As StringBuilder = New StringBuilder(100)

' 获得某一个句柄的类名

GetClassName(hwnd, dwWindowClass, 100)

If dwWindowClass.ToString.Contains("EDIT") Or dwWindowClass.ToString.Contains("Edit") Then     ' 类名包含EDIT的为编辑框

EditHandle.Add(hwnd)                        ' 存储该句柄

End If

' 返回 True 一直枚举完

Return True

End Function

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

WindowHandle = FindWindow(vbNullString, "登陆")

If WindowHandle.ToInt32 = 0 Then

MsgBox("未捕获到窗口" + "登陆")

Return

End If

' 枚举所有主窗口的子窗口(控件),枚举时自动调用回调函数,完成编辑框句柄的获取

EnumChildWindows(WindowHandle, AddressOf EnumChildProcC, 0)

' 寻找复选框

CheckHandle = FindWindowEx(WindowHandle, IntPtr.Zero, vbNullString, "记住密码")

Dim str As New StringBuilder

Dim j As Integer = 0

' 对编辑框文本赋值

For j = 0 To EditHandle.Count - 1

SendMessage(EditHandle(j), WM_SETTEXT, 0, "Text")

'GetWindowText(EditHandle(j), str, 20)

'EditWindowsText.Add(Str.ToString)

'Str.Clear()

Next

If EditHandle.Count = 0 Then

MsgBox("未找到输入框!")

End If        

If CheckHandle.ToInt32  0 Then

'CheckDlgButton(WindowHandle, id, 1)

' 对复选框进行鼠标单击操作

SendMessage(CheckHandle, BM_CLICK, 0, 0)

'SendMessage(CheckHandle, BM_SETCHECK, True, 0)

End If

End Sub

End Class

求一个VB.net 增删改查实例 ,哪位大神有空帮我写一下或者有现成的给我一个,,我比较菜又比较急,在线等

Imports System.Data.OleDb

'Imports System.Data.OracleClient

Imports System.Data.SqlClient

'链接Oracle

'cn = New SqlConnection(""Data Source=TNS名称;Persist Security Info=True;User ID=用户名;Password=密码;" ")

'Imports System.Data.OracleClient

'Dim oOracleConn As OracleConnection = New OracleConnection()

'oOracleConn.ConnectionString = ""Data Source=MyOracleDB; User Id=username; Password=passwd; Integrated Security=no; "

'oOracleConn.Open()

'链接SQL Server

'cn = New SqlConnection("Data Source=.;Initial Catalog=Sales;Integrated Security=False;User ID=sa;Password=;")

'链接Access

'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

Public Class Fun_DataBase

Dim cn As OleDbConnection

Dim cm As OleDbCommand

Dim da As OleDbDataAdapter

Dim ds As DataSet

Dim db_path As String = "D:\Documents\Visual Studio 2013\Projects\VBnet1\VBnet1\Resources\Database1.mdb"

Function Fun_sql1(Str_sql As String, V_调用来源 As String) '按指定sql,反馈1个查询值

Try

'Dim cn As New OleDbConnection("Data Source=.;Initial Catalog=Sales;Integrated Security=False;User ID=sa;Password=123456;")

'链接Access

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

cn.Open() 'sql语句执行前,必须打开连接

cm = New OleDbCommand(Str_sql, cn)

cm.ExecuteNonQuery()

Dim strValue As String = cm.ExecuteScalar.ToString

'MessageBox.Show(strValue)

Fun_sql1 = strValue

cn.Close()

Fun_sql1 = True

Catch ex As Exception

MessageBox.Show(V_调用来源 ":执行sql语句失败!" Str_sql)

Fun_sql1 = False

End Try

End Function

Function Fun_sqln(Str_sql As String, V_调用来源 As String) '按指定sql,反馈1行n列查询值

Try

'链接Access

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

cn.Open() 'sql语句执行前,必须打开连接

Dim cmd As New OleDbCommand("select * from grade", cn)

'Dim dr As SqlDataReader

Dim dr As OleDbDataReader

dr = cmd.ExecuteReader()

Dim strDisplay As String = ""

While dr.Read()

Fun_sqln = dr(0).ToString "|"

End While

cn.Close()

Fun_sqln = True

Catch ex As Exception

MessageBox.Show(V_调用来源 ":执行sql语句失败!" Str_sql)

Fun_sqln = False

End Try

'Dim s = Split(F.Fun_sqln("ef"), "|")

'Dim i As Integer

'i = UBound(s)

'For i = 0 To UBound(s)

' MessageBox.Show(s(i))

'Next

End Function

Public Function Fun_sql_exec(Str_sql As String, V_调用来源 As String) '执行指定sql,反馈T|F

Try

'链接Access

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

cn.Open() 'sql语句执行前,必须打开连接

cm = New OleDbCommand(Str_sql, cn)

cm.ExecuteNonQuery()

cn.Close()

Fun_sql_exec = True

Catch ex As Exception

MessageBox.Show(V_调用来源 ":执行sql语句失败!" Str_sql)

Fun_sql_exec = False

End Try

End Function


文章标题:vb.net实例大全的简单介绍
当前路径:http://cdxtjz.cn/article/hjgdei.html

其他资讯