预览模式: 普通 | 列表

vb.net判断重复文本并提取

Dim data As New List(Of String) ' 保存2000000条数据的列表
' 假设数据已经保存在 data 列表中

Dim countDict As New Dictionary(Of String, Integer) ' 字典用于保存每条数据的重复次数

For Each item As String In data
If countDict.ContainsKey(item) Then
countDict(item) += 1 ' 如果字典中已经存在这条数据,重复次数加1
Else
countDict(item) = 1 ' 如果字典中不存在这条数据,添加到字典中并初始化重复次数为1
End If
Next

' 输出重复次数大于1的数据
For Each item As KeyValuePair(Of String, Integer) In countDict
If item.Value > 1 Then
Console.WriteLine("{0}: {1}", item.Key, item.Value)
End If
Next

Tags: vb.net

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 494

vb.net正则判断ip端口格式

Dim ip As String = "192.168.0.1"

' 创建正则表达式对象
Dim regex As New System.Text.RegularExpressions.Regex("^(\d{1,3}\.){3}\d{1,3}$")

' 判断是否是 IP 地址
If regex.IsMatch(ip) Then
Console.WriteLine("The string is an IP address.")
Else
Console.WriteLine("The string is not an IP address.")
End If


Dim ipAndPort As String = "192.168.0.1:8080"

查看更多...

Tags: vb.net

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 416

vb.net多线程下载

 Imports System.IO
Imports System.Net
Imports System.Threading

Public Class Form1
Private downloadThreads As List(Of Thread) = New List(Of Thread)()
Private downloadUrls As List(Of String) = New List(Of String)()

Private proxy As WebProxy = New WebProxy("http://proxy.example.com:8080")
Private threadCount As Integer = 10

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' 添加需要下载的网址
For i As Integer = 1 To 10000
downloadUrls.Add("http://example.com/file" & i & ".jpg")
Next
End Sub

查看更多...

Tags: vb.net

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 506

vb.net多线程下载

Imports System.IO
Imports System.Net
Imports System.Threading

Public Class Form1
Private downloadThreads As List(Of Thread) = New List(Of Thread)()
Private downloadUrls As List(Of String) = New List(Of String)()

Private proxy As WebProxy = New WebProxy("http://proxy.example.com:8080")
Private threadCount As Integer = 10

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' 添加需要下载的网址
For i As Integer = 1 To 10000
downloadUrls.Add("http://example.com/file" & i & ".jpg")
Next
End Sub

查看更多...

Tags: vb.net

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 488

vb.net多线程下载

Imports System.IO
Imports System.Net
Imports System.Threading

Public Class Form1
Private downloadThreads As List(Of Thread) = New List(Of Thread)()
Private downloadUrls As List(Of String) = New List(Of String)()

Private proxy As WebProxy = New WebProxy("http://proxy.example.com:8080")

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' 添加需要下载的网址
downloadUrls.Add("http://example.com/file1.jpg")
downloadUrls.Add("http://example.com/file2.jpg")
downloadUrls.Add("http://example.com/file3.jpg")
downloadUrls.Add("http://example.com/file4.jpg")
downloadUrls.Add("http://example.com/file5.jpg")
End Sub

查看更多...

Tags: vb.net

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 417

Telegram机器人如何获取群组chat id?

要获取群聊id,请执行以下操作:

 

将Telegram BOT添加到组中。

 

查看更多...

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 438

vb.net 分割字符用split快还是用mid快?

在 VB.NET 中,使用 Split 方法和使用 Mid 函数进行字符串分割是两种不同的方法,它们的使用场景和性能特点也有所不同。

Split 方法是用于将字符串按照指定的分隔符拆分为子字符串数组的功能强大的方法。它可以根据指定的分隔符将字符串分割成多个部分,并将每个部分作为数组元素返回。例如,你可以使用 Split 方法按照空格字符来分割句子成单词。

Mid 函数则是用于提取字符串的子串的方法。它接受三个参数:要提取的字符串,起始位置和要提取的字符数。通过调用 Mid 函数,你可以从指定的位置开始提取指定数量的字符,并返回提取的子串。

当需要将字符串按照某个特定的分隔符进行拆分时,使用 Split 方法是更直观和方便的选择。它可以更轻松地处理分隔符可能存在多个连续的情况,并返回一个字符串数组,你可以直接访问和操作各个分割后的部分。

查看更多...

Tags: vb.net

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 369

php生成渐变图片并添加水印

现在还有个问题,就是渐变色只能是灰色,不清楚什么原因。。

PHP代码
  1. // 创建画布  
  2. $imageWidth = 720;  
  3. $imageHeight = 480;  
  4. $image = imagecreatetruecolor($imageWidth$imageHeight);  
  5.   
  6. // 生成随机渐变  
  7. $startColor = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));  
  8. $endColor = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));  
  9.   
  10. // 填充渐变背景  
  11. for ($y = 0; $y < $imageHeight$y++) {  
  12.     $progress = $y / ($imageHeight - 1);  
  13.   
  14.     $r = lerp($startColor$endColor$progress'red');  
  15.     $g = lerp($startColor$endColor$progress'green');  
  16.     $b = lerp($startColor$endColor$progress'blue');  
  17.   
  18.     $color = imagecolorallocate($image$r$g$b);  
  19.     imagefilledrectangle($image, 0, $y$imageWidth - 1, $y$color);  
  20. }  
  21.   
  22. // 添加水印文字  
  23. $watermarkText = $title;  
  24. $font = 'fonts/msyh.ttc';  // 替换为实际的字体文件路径  
  25. $fontSize = 20;  
  26. $fontColor = imagecolorallocate($image, 255, 255, 255);  
  27. $padding = 10;  
  28. $box = imagettfbbox($fontSize, 0, $font$watermarkText);  
  29. $textWidth = $box[2] - $box[0];  
  30. $textHeight = $box[1] - $box[7];  
  31. $textX = $imageWidth - $textWidth - $padding;  
  32. $textY = $imageHeight - $textHeight - $padding;  
  33. imagettftext($image$fontSize, 0, $textX$textY$fontColor$font$watermarkText);  
  34.   
  35. // 输出图片  
  36. header('Content-type: image/png');  
  37. imagepng($image);  
  38. imagedestroy($image);  
  39.   
  40. // 辅助函数,用于线性插值  
  41. function lerp($startColor$endColor$progress$channel) {  
  42.     $start = $startColor & 0xFF;  
  43.     $end = $endColor & 0xFF;  
  44.     return (int) round($start * (1 - $progress) + $end * $progress);  
  45. }  

 

Tags: php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 381

 广告位

↑返回顶部↑