VB.NET中的函数应用方式是一个比较基础的知识点。我们可以通过实践来积累经验,充分掌握这些函数的应用方法。在这里我们就先为大家详细介绍几个VB.NET基本函数的应用方法,希望能给大家带来一些帮助。
成都创新互联2013年至今,是专业互联网技术服务公司,拥有项目网站设计制作、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元天台做网站,已为上家服务,为天台各地企业和个人服务,联系电话:13518219792
判断该窗体是否已经打开
- Public Function OpenForm
(ByVal myform As Form, ByVal
MdiForm As Form) As Boolean- Dim form As Form
- For Each form In MdiForm.
MdiChildren- If form.Text = myform.
Text Then- form.Activate()
- Return True
- End If
- Next
- Return False
- End Function
系统退出时的代码
- Public Sub ExitSystem
(ByVal Form_Name As String)- If Form_Name = "Exit" Then
- ' If MsgBox("您真的要退出文件管理系统吗?",
MsgBoxStyle.YesNo + MsgBoxStyle.
Question, "退出系统") =
MsgBoxResult.Yes Then- Application.Exit()
- End
- 'End If
- End If
- End Sub
判断字符是否为数字型,当为数字时返回True,不为时返回False
- Public Function IsNumeric
(ByVal strText As String)
As Boolean- Dim charstr As Char
- For Each charstr In strText
- If Not Char.IsNumber
(charstr) Then- Return False
- End If
- Next
- Return True
- End Function
加密函数
- Function EnPas(ByVal CodeStr
As String) As String- Dim CodeLen As Integer = 30
- Dim CodeSpace, Been, NewCodeInt
As Integer- Dim EnPasStr As String = ""
- Dim NewCode As String
- CodeSpace = CodeLen - CodeStr.Length
- If Not CodeSpace < 1 Then
- For cecr As Integer = 1 To CodeSpace
- CodeStrCodeStr = CodeStr & Chr(21)
- Next
- End If
- NewCodeInt = 1
- NewCode = 1
- For cecb As Integer = 1 To CodeLen
- Been = CodeLen + Asc(CodeStr.
Substring(cecb - 1, 1)) * cecb- NewCodeNewCode = NewCode * Been
- Next
- CodeStr = NewCode
- NewCode = Nothing
- For cec As Integer = 1 To CodeStr.Length
- Try
- NewCodeNewCode = NewCode &
CfsCode(CodeStr.Substring(cec - 1, 3))- Catch ex As Exception
- Try
- NewCodeNewCode = NewCode & CfsCode
(CodeStr.Substring(cec - 1, 2))- Catch exs As Exception
- NewCodeNewCode = NewCode & CfsCode
(CodeStr.Substring(cec - 1, 1))- End Try
- End Try
- Next
- For cec As Integer = 20 To NewCode.
Length - 18 Step 2- EnPasStrEnPasStr = EnPasStr & NewCode.
Substring(cec - 1, 1)- Next
- Return EnPasStr
- End Function
加密子函数
- Function CfsCode(ByVal Word
As String) As String- Dim CfsCodeStr As String = ""
- For cc As Integer =
1 To Word.Length- CfsCodeStrCfsCodeStr =
CfsCodeStr & Asc(Word.
Substring(cc - 1, 1))- Next
- CfsCodeStr = Hex(CfsCodeStr)
- Return CfsCodeStr
- End Function
打开某一个程序 程序的路径
- Public Function Openfile
(ByVal FilePath As String)
As Boolean- Try
- System.Diagnostics.Process.
Start(FilePath)- Return True
- Catch ex As Exception
- MsgBox(ex.Message)
- Return False
- Exit Function
- End Try
- End Function
- #Region " XML文件操作部分(系统设置) "
- Public Sub RendXml(ByVal
filename As String)- Dim falg As Boolean = True
- Dim fi As System.IO.FileInfo
- fi = New System.IO.FileInfo(filename)
- If fi.Exists Then
- Dim doc As New XmlDocument
- doc.Load(filename)
- Dim nodeRoot = doc.DocumentElement
连接数据库的IP、数据库名称、用户名、密码
- Sys_Data_Source = nodeRoot.
SelectSingleNode("Sys_Data_Source")
.InnerText- Sys_Data_Catalog = nodeRoot.
SelectSingleNode("Sys_Data_Catalog")
.InnerText- Sys_Data_User = nodeRoot.
SelectSingleNode("Sys_Data_User")
.InnerText- Sys_Data_Password = nodeRoot.
SelectSingleNode("Sys_Data_Password")
.InnerText- Else
- MessageBox.Show("系统初始化出错,
请与系统管理员联系!!", "严重警告",
MessageBoxButtons.OK, MessageBoxIcon.Error)- End
- End If
- End Sub
- #End Region
VB.NET基本函数的相关概念就为大家介绍到这里。
分享名称:VB.NET基本函数内容概述
网页URL:http://www.shufengxianlan.com/qtweb/news48/198298.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联