真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

關(guān)于vb.net程序?qū)嵗男畔?/h1>

VB.net生成單個實(shí)例應(yīng)用程序

就是只允許啟動單一個應(yīng)用程序的實(shí)例, 試圖啟動第二次時不會產(chǎn)生新的實(shí)例,并激活已經(jīng)啟動的實(shí)例.

成都創(chuàng)新互聯(lián)是一家專注于網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),新市網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:新市等地區(qū)。新市做網(wǎng)站價格咨詢:028-86922220

VB.net實(shí)例

1 生成txt文件。

DimSaveFileDialog1AsNewSaveFileDialog()?'創(chuàng)建一個保存對話框

SaveFileDialog1.Filter?="txt?files?(*.txt)|*.txt"?'設(shè)置擴(kuò)展名

IfSaveFileDialog1.ShowDialog()?=?System.Windows.Forms.DialogResult.OKThen?'如果確定保存

My.Computer.FileSystem.WriteAllText(SaveFileDialog1.Filename,?Textbox1.Text,False)?'保存文本,False表示不追加文本,直接覆蓋其內(nèi)容

EndIf

原文鏈接:

VB.net中類的實(shí)例化

1.不正確

Dim abc As myClass,定義一個可以引用myClass類型對象的變量abc。這個abc變量存在于棧上。

abc=New myClass。New myClass創(chuàng)建myClass實(shí)例對象,這個對象存在于托管堆上。然后(同時)讓abc引用(指向)這個對象。

abc變量在棧上,而對象在托管堆上。

abc儲存的是對象的地址,而不是對象本身。

看下面的代碼

Dim a As myClass,b As myClass,c As myClass

a=New myClass

b=a

c=a

整個過程中只創(chuàng)建了一個myClass對象,位于托管堆上。

三個myClass類型的變量a、b、c位于棧上,都指向了這一個myClass對象

2.類的成員分 實(shí)例成員 和 靜態(tài)成員

實(shí)例成員 必須在實(shí)例對象上調(diào)用

靜態(tài)成員 可以直接調(diào)用,不需要實(shí)例對象。

用VB.NET程序編寫代碼

Delphi代碼如下:

procedure?TForm1.Button1Click(Sender:?TObject);

var

購物總價:Integer;

折扣:Extended;

begin

購物總價:=StrToInt(Edit1.Text);

if?購物總價250?then

begin

折扣:=0;

end

else?if?購物總價500?then

begin

折扣:=0.05;

end

else?if?購物總價1000?then

begin

折扣:=0.075;

end

else?if?購物總價2000?then

begin

折扣:=0.1;

end

{

此段的折扣是多少?

else?if?購物總價3000?then

begin

折扣:=0.05;

end

}

else?if?購物總價=3000?then

begin

折扣:=0.15;

end;

ShowMessage('您享受的折扣是:'+FloatToStr(折扣)

+'?原價:'+IntToStr(購物總價)

+'?折后總價:'+FloatToStr(購物總價*(1-折扣)));

end;

關(guān)于VB.NET進(jìn)度條的實(shí)例

該實(shí)例有很多實(shí)現(xiàn)方法,下面介紹一種不同的給你:

首先要在窗體中載入以下控件:progressbar(進(jìn)度條),label(用來實(shí)時顯示文本提示),兩個timer(分別控制進(jìn)度條進(jìn)度的增減),然后用以下代碼就能實(shí)現(xiàn):

Public Class Form1

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

Timer1.Enabled = True

Timer1.Interval = 500

Timer2.Interval = 500

ProgressBar1.Value = 0

ProgressBar1.Maximum = 100

ProgressBar1.Minimum = 0

End Sub

'上述過程是設(shè)置控件的初始值,也可以在屬性面板設(shè)置

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

ProgressBar1.Value += 1

Label1.Text = "當(dāng)前完成" ProgressBar1.Value "%"

If (ProgressBar1.Value = 100) Then

Timer1.Enabled = False

Timer2.Enabled = True

End If

End Sub

'timer1用來控制進(jìn)度的增加

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

ProgressBar1.Value -= 1

Label1.Text = "當(dāng)前完成" ProgressBar1.Value "%"

If (ProgressBar1.Value = 0) Then

Timer1.Enabled = True

Timer2.Enabled = False

End If

End Sub

'time2用來控制進(jìn)度的減少

End Class

求vb.net句柄實(shí)例,實(shí)現(xiàn)操作其他程序窗口。如我給的例子

Imports?System.Text

Imports?System.Runtime.InteropServices

Public?Class?Form1

'?相關(guān)API函數(shù)聲明,注釋掉的這里沒用到,但是也比較常用吧,這些函數(shù)的功能都能搜到。

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

'?相關(guān)消息定義,也有沒用到的

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)

'?儲存復(fù)選框句柄

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?回調(diào)函數(shù),該函數(shù)名作為API函數(shù)EnumChildWindows?的一個參數(shù)

'?該函數(shù)實(shí)現(xiàn)了枚舉各個子窗口,找出編輯框?qū)傩缘墓δ?/p>

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

'?枚舉所有主窗口的子窗口(控件),枚舉時自動調(diào)用回調(diào)函數(shù),完成編輯框句柄的獲取

EnumChildWindows(WindowHandle,?AddressOf?EnumChildProcC,?0)

'?尋找復(fù)選框

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)

'?對復(fù)選框進(jìn)行鼠標(biāo)單擊操作

SendMessage(CheckHandle,?BM_CLICK,?0,?0)

'SendMessage(CheckHandle,?BM_SETCHECK,?True,?0)

End?If

End?Sub

End?Class


網(wǎng)站欄目:關(guān)于vb.net程序?qū)嵗男畔?
文章位置:http://weahome.cn/article/hjspho.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部