随笔分类 - VB.NET
VB.NET编程学习随笔
摘要:获取当前时间 Dim currentDateTime As DateTime ' 获取当前的日期和时间 currentDateTime = DateTime.Now ' 显示当前的日期和时间 Console.WriteLine("当前的日期和时间是: " & currentDateTime.ToSt
阅读全文
摘要:' 确保已经将AxWindowsMediaPlayer控件添加到了窗体上,并命名为axWindowsMediaPlayer ' 在窗体的类中添加PlayStateChange事件的处理程序 Private Sub axWindowsMediaPlayer_PlayStateChange(sender
阅读全文
摘要:在VB.NET中,你可以使用DateTime类来计算一个特定日期是几月几日。以下是一个简单的例子,展示了如何计算第189天是哪一月的哪一天: Sub Main() Dim year As Integer = 2023 ' 你可以根据需要更改年份 Dim days As Integer = 189 '
阅读全文
摘要:vb.net 查看本地计算机串口 在VB.NET中,您可以使用System.IO.Ports.SerialPort类来查看本地计算机的串口。以下是一个简单的示例代码,用于列出所有可用的串口名称: 代码1 Imports System.IO.Ports Module ListSerialPortsMo
阅读全文
摘要:' 假设listBox1 和 textbox1 已经在你的窗体上定义 Dim sb As New System.Text.StringBuilder() For Each item As Object In ListBox1.Items sb.AppendLine(item.ToString())
阅读全文
摘要:' 假设TabControl的名字是TabControl1,你想切换到第二页 TabControl1.SelectedIndex = 1 ' 假设你有一个TabPage的实例叫做TabPage2,你想切换到这个页 TabControl1.SelectedTab = TabPage2
阅读全文
摘要:Public Class Form1 ' 当窗体初始化时,订阅键盘按下事件 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load AddHandler Me.KeyDown, AddressOf Fo
阅读全文
摘要:Imports System.Data.SqlClient Public Sub ExecuteStoredProcedure() ' 定义连接字符串,应该根据实际情况修改 Dim connectionString As String = "Server=你的服务器地址;Database=你的数据库
阅读全文
摘要:vb.net中用作处理图形图像的控件有两个:PictureBox和ImageList。PictureBox(图片箱)控件被用来显示图形或者图像,ImageList控件用于存储图形或图像。 PictureBox控件在工具箱中的图标如图所示 一、PictureBox控件的常用属性 1、BackColor
阅读全文
摘要:Private Sub Form_Load() Label1.Font="楷体"'字体改为楷体 Label1.FontSize=50'字体大小 Label1.ForeColor=vbRed'字体颜色改为红色 Label1.AutoSize=True'label随文字内容自动改变大小 End Sub
阅读全文
摘要:VB.Net Switch 语句 Select Case numColumns Case 0 numColumns = numColumns + 1 'Some code Case 1 numColumns = numColumns + 1 'Some different code Case 2 n
阅读全文
摘要:“工具箱”——“所有Windows窗体”中单击右键,选择“选择项”菜单 打开“选择工具箱项”窗口,选择“COM组件”标签, 在列表中找到并勾选“Windows Media Player”组件,单击“确定”按钮 将该组件添加到指定的工具箱选项卡中 然后在工具箱里面找 Windows Media Pla
阅读全文
摘要:1、问题:通过EXCEL上传数据报错:未在本地计算机上注册“icrosoft.ACE.OLEDB.12.0”提供程序 原因是电脑office版本和VB.net程序选择的运行有关系 处理:先查看office是X86还是64位 如果是64位,在VB.NET中更改编译CPU选择X64 方法2:如果是X86
阅读全文
摘要:设置Label属性,如下设置: AutoSize=falseTextAlign=MiddleCenter
阅读全文
摘要:打开软件 start /d "E:\04-软件开发\01-MES程序\02-最新安装客户端\MES最新程序\01-C490\01-生产线\01-C490前排正座\LP030\Debug\"MES.exe @echo offstart E:\test\X.exe
阅读全文
摘要:最小化缩到右下角,用到NotifyIcon,单击右下角图标恢复Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged If Me.Win
阅读全文
摘要:1.Button1.PerformClick() 2.button1_click(sender,e) 使用方法23.button1_click(nothing,nothing) 4.button1_click(sender,nothing)
阅读全文