vb.net测试类的简单介绍

在vb.net中怎么调用自定义类?代码已测试 。
一、测试需要的INI文件 。名称为“setinfo.ini”,存放路径为你解决方案里“Bin“文件夹的”Debug“文件夹里 。
内容:
[Location]
pnlTime.Location.X=787
pnlTime.Location.Y=0
[TopMost]
Top=True
二、操作INI文件的类 。新建一个类,类中内容为:
Public Class Class1
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
( _
ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Int32, _
ByVal lpFileName As String _
) As Int32
End Class
三、界面代码:
Imports System.IO 'for path
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
getINI()
End Sub
Private Sub getINI()
Dim iniclass As New Class1 '
Dim myBf As String 'get set_info 开辟存储的内存
myBf = New String(CChar(""), 256)
Dim myFN As String '配置文件的文件路径
myFN = Path.Combine(My.Application.Info.DirectoryPath, "setinfo.ini")
Dim myAN As String 'Application_NAME,也是Section名称
myAN = Me.TextBox1.Text
Dim myKN As String 'KEY_NAME,关键字名称
myKN = Me.TextBox2.Text
Class1.GetPrivateProfileString(myAN, myKN, "", myBf, myBf.Length, myFN) '调用读取INI文件的操作
TextBox3.Text = Microsoft.VisualBasic.Left(myBf, InStr(myBf, Chr(0)) - 1) '截取有用部分,有必要
End Sub
End Class
四、测试截图如下
VB.net中怎样让程序测试时显示变量的值??如果你是建立的窗体的话,可以用一个messagebox来显示 messagebox.show(n)如果是控制台程序,就可以Console.write(n)
vb.net测试数据库是否能连接serverstring = "Server="服务器IP";DataBase="库名";Userid="用户名";Password="密码
Try
Conn = New MySqlConnection(serverstring)
Conn.Open()
MsgBox("连接成功")
Conn.Dispose()
Conn.Close()
Catch ex As Exception
【vb.net测试类的简单介绍】MsgBox("连接失败!")
End Try
这是 mysql 的 , 自己改成 sql server 的就行了
怎么用vb.net做心理测试 第一个窗口有一张图片 然后在选择A 就弹出一张图片 选择B 弹出用2个单选控件
按钮下 如果 单选控件1状态是选中vb.net测试类的 就显示窗体2 不是则显示窗体3
或者 vb.net测试类你可以显示 图像框控件2
VB.NET怎么编程测试CPU电压'
'?。。≈匾菏紫纫砑印耙谩币桓鰀ll , 选择“System Management”;
'
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Management
Imports System.IO
Namespace WindowsApplication1
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取CPU编号
Dim [MyClass] As New ManagementClass("Win32_Processor")
Dim MyCollection As ManagementObjectCollection = [MyClass].GetInstances()
Dim MyInfo As String = "当前系统CPU编号是:"
Dim MyCPUID As String = ""
For Each MyObject As ManagementObject In MyCollection
MyCPUID = MyObject.Properties("ProcessorId").Value.ToString()
Exit For
Next MyObject
MyInfo = MyCPUID
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

推荐阅读