好像不難吧?
10年的南明網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整南明建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)公司從事“南明網(wǎng)站設(shè)計”,“南明網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
我放進了Button1的Click事件里。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error GoTo Errmessages '在做系統(tǒng)操作時加排錯標簽是個好習慣
Dim TargetName As String = "ibmdict" '存儲進程名為文本型,注:進程名不加擴展名
Dim TargetKill() As Process = Process.GetProcessesByName(TargetName) '從進程名獲取進程
Dim TargetPath As String '存儲進程路徑為文本型
If TargetKill.Length 1 Then '判斷進程名的數(shù)量,如果同名進程數(shù)量在2個以上,用For循環(huán)關(guān)閉進程。
For i = 0 To TargetKill.Length - 1
TargetPath = TargetKill(i).MainModule.FileName
TargetKill(i).Kill()
Next
ElseIf TargetKill.Length = 0 Then '判斷進程名的數(shù)量,沒有發(fā)現(xiàn)進程直接彈窗。不需要的,可直接刪掉該If子句
MsgBox("沒有發(fā)現(xiàn)進程!")
Exit Sub
ElseIf TargetKill.Length = 1 Then '判斷進程名的數(shù)量,如果只有一個,就不用For循環(huán)
TargetKill(0).Kill()
End If
MsgBox("已終止" TargetKill.Length "個進程") '彈窗提示已終止多少個進程
Errmessages: ‘定義排錯標簽
If Err.Description Nothing Then ’判斷有無錯誤,如果有,則 ↓
MsgBox(Err.Description) '當出現(xiàn)錯誤時,彈窗提示
End If
End Sub
可根據(jù)需要自行修改,這個備注夠完善了吧?不會的再Hi我。
先imports
system.runtime.interopservices
然后class
xxxx
public
shared
function
zlibversion()
as
string
end
function...'在里面調(diào)用zlibversion()即可調(diào)用zlib1.dll的zlibversion方法,其他dll你根據(jù)接口靈活定義好了end
class
數(shù)據(jù)類型轉(zhuǎn)換函數(shù):
轉(zhuǎn)換函數(shù)
將表達式轉(zhuǎn)換成
cbool
boolean
cbyte
byte
ccur
currency
'只在vb7.0以下有效
cdate
date
cdbl
double
cint
integer
clng
long
csng
single
cstr
string
cvar
variant
‘只在vb7.0以下有效
cverr
error
'只在vb7.0以下有效
判斷和創(chuàng)建可以放在一起。
創(chuàng)建空文件夾:
Directory.CreateDirectory(文件夾完整路徑)
'系統(tǒng)會自動判斷文件夾是否存在,不存在就創(chuàng)建
判斷并創(chuàng)建空文件:
Using?fs?As?New?FileStream("f.txt",?FileMode.OpenOrCreate)
'你可以用這個FileStream做其它事情??
End?Using
添加:(先在加一個contextMenu,再它的添加子菜單的click事件編程)
Try
’使TreeView可以被編輯
TreeView1.LabelEdit = True
‘判斷你是不是選定的是不可編輯的節(jié)點,我這里工種節(jié)點不可以被編輯,只有工種下級的
各個工種名稱可以被編輯
If Trim(TreeView1.SelectedNode.Text) = "工種" Then
‘添加節(jié)點
AddNode = New TreeNode("請輸入新工種名字")
TreeView1.SelectedNode.Nodes.Add(AddNode)
TreeView1.ExpandAll()
AddNode.BeginEdit()
TreeView1.LabelEdit = True
NodeAdded = True
End If
Catch err As Exception
MsgBox(err.ToString)
End Try
刪除與添加類似,只是如果你的節(jié)點名字從其他處(如數(shù)據(jù)庫)得來,那么你還需要更新數(shù)據(jù)庫
編輯:
Private Sub TreeView1_BeforeLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles TreeView1.BeforeLabelEdit
TreeView1.LabelEdit = True ‘使可以編輯
AddNode = TreeView1.SelectedNode
End Sub
Private Sub TreeView1_AfterLabelEdit(ByVal sender As Object, ByVal e As System.windows.Forms.NodeLabelEditEventArgs) Handles TreeView1.AfterLabelEdit
Try
‘此時你改完了節(jié)點名字
TreeView1.SelectedNode.EndEdit(True)
If e.Label Is Nothing Then
'do nothing
ElseIf e.Node.Text = "工種" Then ‘工種不能改
e.CancelEdit() = True
‘e.Node.Text ,e.Label.ToString 一個是改前的名字一個是該后的名字,具體哪個對
哪個請查MSDN
ElseIf Trim(e.Node.Text) "工種" And e.Node.Text e.Label.ToString Then
If MsgBox("此操作會導致當前工種中的所有人員的工種都被更改,是否確定?", MsgBoxStyle.YesNo + MsgBoxStyle.Information, "警告") = MsgBoxResult.Yes Then
。。。。 ‘我的更改
MsgBox("更改成功!", MsgBoxStyle.OKOnly, "提示")
'Call InitTree() ‘有時要重新把treeview初始化一遍,視需求定
End If
End If
Catch err As Exception
MsgBox(err.ToString)
End Try
End Sub
其他:
擋treeview得到焦點時你可以使用ContextMenu,反之ContextMenu禁用
Private Sub TreeView1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.GotFocus
TreeView1.ContextMenu = ContextMenu1
End Sub
Private Sub TreeView1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.LostFocus
TreeView1.ContextMenu = Nothing
End Sub
注意:這里沒有在ContextMenu菜單添加“更改”項,而是直接更改:即左鍵單擊節(jié)點表示
選中,再單擊一下就可以編輯了,更改之后單擊他處就完成更改,和你在windows中更改文
件名字相似。
分享文章:vb.net判斷err vb和net的關(guān)系
轉(zhuǎn)載注明:http://m.kartarina.com/article4/hgjoie.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、網(wǎng)站維護、手機網(wǎng)站建設(shè)、動態(tài)網(wǎng)站、ChatGPT、網(wǎng)站營銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)