网站首页 > 文章中心 > 其它

vb.net源码宝典

作者:小编 更新时间:2023-10-08 19:13:45 浏览量:392人看过

求一个VB.NET进行局域网内UDP广播的源代码例子

给你个udp多播例子,广播不是很清楚,呵呵

Imports System.Net

Imports System.Net.Sockets

Imports System.Text

Public Class Form1

Inherits System.Windows.Forms.Form

Dim port As String

Dim ipadd As String

Dim ipend As IPEndPoint

Dim sendudp As New UdpClient()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _

Handles Button1.Click

Dim ipadress As IPAddress

ipadress = IPAddress.Parse(TextBox1.Text)

'ipend = New IPEndPoint(ipadress, sendport)

Try

sendudp.JoinMulticastGroup(ipadress)

MessageBox.Show("启动完成!")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

如何用vb.net获得网页的源代码

Dim url As String=" 网址"

Dim httpReq As System.Net.HttpWebRequest

Dim httpResp As System.Net.HttpWebResponse

Dim httpURL As New System.Uri(url)

httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)

httpReq.Method = "GET"

httpResp = CType(httpReq.GetResponse(), HttpWebResponse)

httpReq.KeepAlive = False ' 获取或设置一个值,该值指示是否与

Internet资源建立持久连接.

Dim reader As StreamReader = _

New StreamReader(httpResp.GetResponseStream,

System.Text.Encoding.GetEncoding(-0))

Dim respHTML As String = reader.ReadToEnd() 'respHTML就是网页源代码

代码宝典-Vb.Net之多媒体应用技术的注册码

用vb.net编写记事本源代码

Dim sFileName As String

Dim Search

Private Sub dateTimeMenu_Click()

Text1.Text = Now

Private Sub deleteMenu_Click()

Text1.Text = Left(Text1.Text, Text1.SelStart) ◆ Mid(Text1.Text, Text1.SelStart ◆ Text1.SelLength ◆ 1)

Private Sub findMenu_Click()

Search = InputBox("请输入要查找的字词:")

Dim Where1 '获取需要查找的字符串变量

Text1.SetFocus '文本框获得焦点,以显示所找到的内容Search = InputBox("请输入要查找的字词:")

Where1 = InStr(Text1.Text, Search) '在文本中查找字符串

If Where1 Then

'若找到则设置选定的起始位置并使找到的字符串高亮

Text1.SelStart = Where1 - 1

Text1.SelLength = Len(Search)

' Me.Caption = Where1 '测试用

'否则给出提示

Else: MsgBox "未找到所要查找的字符串.", vbInformation, "提示"

End If

Private Sub findNextMenu_Click()

Dim StartMe As Integer '查找的起始位置变量

Text1.SetFocus '文本框获得焦点

StartMe = Text1.SelLength ◆ Text1.SelStart ◆ 1 '给变量赋值

Private Sub aboutMenu_Click()

Private Sub allMenu_Click()

Text1.SelStart = 0

Text1.SelLength = Len(Text1.Text)

Private Sub backcolorMenu_Click() '设置背景色代码

Text1.BackColor = Form1.CommonDialog1.Color

Private Sub colorMenu_Click() '改变文字颜色代码

Text1.ForeColor = Form1.CommonDialog1.Color

Private Sub cutMenu_Click()

Clipboard.SetText Text1.SelText

Private Sub exitMenu_Click()

End

Private Sub fontMenu_Click() '字体菜单代码

If Len(Form1.CommonDialog1.FontName) = 0 Then

Form1.Text1.FontName = "宋体"

Else

Form1.Text1.FontName = Form1.CommonDialog1.FontName

Form1.Text1.FontSize = Form1.CommonDialog1.FontSize

If Form1.CommonDialog1.FontBold = True Then

Form1.Text1.FontBold = True

Form1.Text1.FontBold = False

If Form1.CommonDialog1.FontItalic = True Then

Form1.Text1.FontItalic = True

Form1.Text1.FontItalic = False

Private Sub Form_Load()

Form1.Text1.Height = Form1.Height

Private Sub Form_Resize()

Private Sub help1Menu_Click()

Form1.CommonDialog1.HelpCommand = cdlHelpForceFile

CommonDialog1.ShowHelp

Private Sub newMenu_Click()

If Len(Trim(Text1.Text)) = 0 Then

Form1.Caption = "我的记事本" "--" "未命名"

sFileName = "未命名"

Text1.FontName = "宋体"

Text1.Text = ""

Call saveAsMenu_Click

Private Sub openMenu_Click() '打开文件代码

Form1.Caption = "我的记事本"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Action = 1

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Form1.Caption = Form1.Caption "--" Form1.CommonDialog1.FileTitle

Open sFileName For Input As #1

Do While Not EOF(1)

Line Input #1, Text$

Loop

Text1.Text = All

Close #1

Private Sub pasteMenu_Click() '粘贴菜单代码

Text1.Text = Left(Text1.Text, Text1.SelStart) ◆ Clipboard.GetText() ◆ Mid(Text1.Text, Text1.SelStart ◆ Text1.SelLength ◆ 1)

Private Sub printMenu_Click()

Form1.CommonDialog1.ShowPrinter

For i = 1 To CommonDialog1.Copies

Printer.Print Text1.Text

Next

Printer.EndDoc

Private Sub saveAsMenu_Click() '另存为菜单代码

If Len(Trim(Text1.Text)) 0 Then

Form1.CommonDialog1.DialogTitle = "保存文件"

Form1.CommonDialog1.InitDir = "D:\"

Form1.CommonDialog1.ShowSave

Open sFileName For Output As #1

whole$ = Text1.Text

Print #1, whole

Private Sub saveMenu_Click()

Form1.CommonDialog1.FileName = "新建文本"

Private Sub statusMenu_Click()

如何用vb.net获取网页源代码

使用webbrowser控件来加载网页,然后再

Private

Sub

WebBrowser

①._DocumentCompleted下通过使用WebBrowser1.Document.Body.

InnerHtml

来获取网页的源代码,或使用

WebBrowser1.Document.Body.InnerText来获取网页中的文本.之后可以通过字符串控制指令或者

正则表达式

来精确获取到你所需的数据.

以上就是土嘎嘎小编为大家整理的vb.net源码宝典相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章