关于vb.net中socket编程实例:服务器端的一些问题Socket类连接后 可以通过类中的 RemoteEndPoint 来获取远程IP和端口信息.
要注意的是.需要将它强制转化为 IPEndPoint类型 然后通过 IPEndPoint.Address以及IPEndPoint.Port来获取对应的IP及端口
例:
Dim REV_SCK As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
'这里创建一个UDP Socket连接的实例 TCP也是一样的
'省略SOCKET连接的代码 当SOCKET连接成功后 可以用下面的语句获取远程信息
Dim IP as string ,Port as integer
'定义IP和Port变量 用来保存地址及端口
IP = IPAddress.Parse(CType(REV_SCK.RemoteEndPoint, IPEndPoint).Address.ToString())
Port = IPAddress.Parse(CType(REV_SCK.RemoteEndPoint, IPEndPoint).Port)
用VB.NET编写以下程序 。using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Timer tm = new Timer();//实例化 timeer
static int timeS = 0; //设置静态变量记录秒数
TimeSpan ts = new TimeSpan(); //实例化 TimeSpan
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
tm.Interval = 1000; //设置 timeer 1000毫秒执行一次
tm.Tick += new EventHandler(timeer_Tick); //设置 timeer 运行事件
tm.Start(); // 启用 timeer
}
private void timeer_Tick(object sender, EventArgs e)
{
timeS += 1; //秒数 +1
ts = new TimeSpan(0, 0, timeS);
label1.Text = ts.Hours + ":" + ts.Minutes + ":" + ts.Seconds;
【vb.net编程案例 vbnet web编程】
}
private void button2_Click(object sender, EventArgs e)
{
tm.Stop();
timeS = 0;
}
}
}
VB.NET 拖动无边框窗体编程实例 Imports System Drawing Imports System Windows Forms****************************************** Private oOriginalRegion As Region = Nothing用于窗体移动 Private bFormDragging As Boolean = False Private oPointClicked As Point****************************************** Private Sub Form _MouseDown(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseDown Me bFormDragging = True Me oPointClicked = New Point(e X e Y) End Sub****************************************** Private Sub Form _MouseUp(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseUp Me bFormDragging = False End Sub****************************************** Private Sub Form _MouseMove(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseMove If Me bFormDragging Then Dim oMoveToPoint As Point以当前鼠标位置为基础 找出目标位置 oMoveToPoint = Me PointToScreen(New Point(e X e Y))根据开始位置作出调整 oMoveToPoint Offset(Me oPointClicked X * _ (Me oPointClicked Y + _ SystemInformation CaptionHeight + _ SystemInformation BorderSize Height) * )移动窗体 Me Location = oMoveToPoint End If
lishixinzhi/Article/program/ASP/201311/21755
VB.net实例1 生成txt文件 。
DimSaveFileDialog1AsNewSaveFileDialog() '创建一个保存对话框
SaveFileDialog1.Filter ="txt files (*.txt)|*.txt" '设置扩展名
IfSaveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OKThen '如果确定保存
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.Filename, Textbox1.Text,False) '保存文本,False表示不追加文本vb.net编程案例,直接覆盖其内容
EndIf
原文链接vb.net编程案例:
求vb.net句柄实例,实现操作其他程序窗口 。如我给的例子Imports System.Text
Imports System.Runtime.InteropServices
Public Class Form1
' 相关API函数声明,注释掉的这里没用到,但是也比较常用吧 , 这些函数的功能都能搜到 。
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
推荐阅读
- word如何转ppt,word如何转PPT
- ios手机改120帧教程,iphone改120帧率教程无需电脑
- net框架安装完后不能用,net框架组件
- asp.net中显示一张表,aspnet viewbag
- java高级代码教程 java编程高级教程
- 怎么发微信视频号不被压缩,微信视频号怎么发更清晰
- 包含mongodbloglevel的词条
- jpg能转pdf么,jpg可以转成pdf
- php数据库预执行 php执行数据库查询语句