晨彦电脑科技 Belong to oneself's sky
RSS
一些VB VB.NET编程源码心得
雪糕先生 发布于 2011/06/29 11:00 不指定
这里以关闭一些常见浏览器进程为例子,下面为VB.NET代码我所用的环境为VB2008:
Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(5041) , Via 本站原创
雪糕先生 发布于 2011/06/04 11:26 不指定
判断当前网络是否连接正常可以引用My.Computer.Network的IsAvailable属性,方法如下:
Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(3830) , Via 本站原创
雪糕先生 发布于 2011/01/11 20:48 不指定
下面以动态加入一个Button按钮为例,在窗体加入一个名为Button1的按钮,下面是源代码:
引用

Public Class Form1
    '动态加入控件实例 晨彦电脑科技 WWW.BTOSS.COM
    Private Sub newbutton_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MsgBox("动态加入控件实例 晨彦电脑科技 WWW.BTOSS.COM")
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim newbutton As New Button
        newbutton.Text = "newbutton"
        AddHandler newbutton.Click, AddressOf newbutton_click
        Me.Controls.Add(newbutton)
    End Sub
End Class
Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(3668) , Via 本站原创
雪糕先生 发布于 2011/01/02 21:42 不指定
VB.NET删除文本框TextBox1.Text 中空行的方法:
引用

        '删除文本框中空行的方法 晨彦电脑科技 www.btoss.com
        Dim Row1, Row2 As Integer
        Dim line() As String
        Dim ArList As New ArrayList
        If Me.TextBox1.Text <> "" Then'当文本框为空时
            Row1 = Me.TextBox1.Lines.Length - 1
            For i = 0 To Row1
                If Me.TextBox1.Lines(i).ToString <> "" Then'当行不为空时
                    ArList.Add(Trim(Me.TextBox1.Lines(i).ToString))
                End If
            Next
            Row2 = ArList.Count - 1
            ReDim line(Row2)
            For i = 0 To Row2
                line(i) = ArList.Item(i).ToString
            Next
            Me.TextBox1.Lines = line
        End If
Actions
Tags:
 
VB VB.NET , 评论(1) , 引用(0) , 阅读(6185) , Via 本站原创
雪糕先生 发布于 2011/01/01 19:36 不指定
下面是VB.NET 修改桌面壁纸的方法:
引用
Public Class Form1
    '晨彦电脑科技 www.btoss.com
    Private Const SPI_SETDESKWALLPAPER As Integer = &H14
    Private Const SPIF_UPDATEINIFILE As Integer = &H1
    Private Const SPIF_SENDWININICHANGE As Integer = &H2
    Private Declare Auto Function SystemParametersInfo Lib "user32.dll" ( _
    ByVal uAction As Integer, ByVal uParam As Integer, _
    ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "图片地址", 1)
    End Sub
End Class
Actions
Tags:
 
VB VB.NET , 评论(3) , 引用(0) , 阅读(6462) , Via 本站原创
雪糕先生 发布于 2010/12/27 13:07 不指定
下面是列出当前文件夹中所有JPG图片文件名的方法:
Dim str As String
        For Each file In My.Computer.FileSystem.GetFiles(Application.StartupPath)
            If System.IO.Path.GetExtension(file) = ".jpg" Then
                str = System.IO.Path.GetFileNameWithoutExtension(file)
                ListBox1.Items.Add(Application.StartupPath & str & ".jpg")
            End If
        Next
Actions
Tags:
 
VB VB.NET , 评论(2) , 引用(0) , 阅读(4800) , Via 本站原创
雪糕先生 发布于 2010/12/26 20:35 不指定
写程序的时候,有时需要获取一些系统的信息资料,下面列出方法:
获取此本地计算机的名称:
MsgBox (Environment.MachineName)

获取操作系统版本:
MsgBox(Val(Environment.OSVersion.Version.ToString))

Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(4601) , Via 本站原创
雪糕先生 发布于 2010/12/16 13:24 不指定
下面是创建代码:
引用

        If File.Exists("C:\abc.txt") Then
            File.Delete("C:\abc.txt")
        End If
        Dim sr As StreamWriter = File.CreateText("C:\abc.txt")
        sr.Write("晨彦电脑科技")
        sr.WriteLine("WWW.BTOSS.COM")
        sr.Write("这是一个创建文本文件的例子")
        sr.Close()


下面是读取代码:
Actions
Tags:
 
VB VB.NET , 评论(4) , 引用(0) , 阅读(7099) , Via 本站原创
雪糕先生 发布于 2009/12/27 19:52 不指定
在窗体加入一个COM按钮两个TEXT文本框,一个Webbrowser,下面是窗体源码:
Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(4618) , Via 本站原创
雪糕先生 发布于 2009/12/19 13:24 不指定
把EXE加入到VB工程资源中,这是个不错的方法,下载是vb源代码:
Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(3349) , Via 本站原创
雪糕先生 发布于 2009/12/19 13:11 不指定
下面是检测显示分辨率方法的源代码:
Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(3214) , Via 本站原创
雪糕先生 发布于 2009/11/28 17:10 不指定
加入Microsoft Internet Controls控件,在窗体中加入一个Webbrowser,两个TextBox文本框,一个CommandButton按钮,下面是代码:
Actions
Tags:
 
VB VB.NET , 评论(0) , 引用(0) , 阅读(5136) , Via 本站原创
分页: 1/2 第一页 1 2 下页 最后页 [ 显示模式: 摘要 | 列表 ]
赞助商链接
热门Tags
统计