大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
不需要用数组:
创新互联公司是一家以网络技术公司,为中小企业提供网站维护、网站设计、成都网站建设、网站备案、服务器租用、空间域名、软件开发、微信小程序开发等企业互联网相关业务,是一家有着丰富的互联网运营推广经验的科技公司,有着多年的网站建站经验,致力于帮助中小企业在互联网让打出自已的品牌和口碑,让企业在互联网上打开一个面向全国乃至全球的业务窗口:建站欢迎联系:13518219792
假设已经存在的图片文件存放在 C:\图片 文件夹里,并假设新创建的文件夹位于C:\图片 文件夹里。
在窗体上添加一个按钮,代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Long = -1
Dim P As Long = -1
Dim Pn As String
Dim MyNum As Integer = 100 '每100个文件存放在一个文件夹里
Dim MyPath As String
Dim MyFileName As String
Button1.Enabled = False
MyPath = "C:\图片\" '指定已有图片的路径
MyFileName = UCase(Dir(MyPath, FileAttribute.Normal)) ' 找寻第一项。
Do While MyFileName "" ' 开始循环。
If InStr(MyFileName, "JPG") 0 Or InStr(MyFileName, "GIF") 0 Or InStr(MyFileName, "PNG") 0 Then
n = n + 1
If n \ MyNum P Then
P = P + 1
Pn = CStr(n \ MyNum + 1)
MkDir(MyPath Pn)
End If
FileCopy(MyPath MyFileName, MyPath Pn "\" MyFileName)
End If
MyFileName = UCase(Dir()) ' 查找下一项
Loop
Button1.Enabled = True
End Sub
代码通过测试。
很简单
Dim s As String = "1,2,3,4,5"
Dim a As String() = s.Split(",")
a就是包含所有数字的数组啦,祝你好运。
简单,思路:
1、将每行数据放到数组
2、把”:“作为分隔符拿到你想要的字符串
程序如下:
dim ArrTemp() as string
ArrTemp=split(你的这堆字符,vbcrlf)
dim i as int
dim ArrTemp1() as string
for i=0 to ubound(ArrTemp)
ArrTemp1=split(ArrTemp(i),":")
msgbox left(ArrTemp1(1),len(ArrTemp1(1))-1)
next
Dim str0 As String, idx As Long, str1 As String, str2 As String
str0 = "122012312}R4561_456}7894321}1234123123}"
idx = str0.IndexOf("}")
Do While idx = 0
str1 = str0.Substring(0, idx)
str2 = str0.Substring(idx + 1)
'在文本框中添加显示str1、str2,代码略
str0 = str2
idx = str0.IndexOf("}")
Loop
当然可以的,需要System.Runtime.InteropServices 命名空间中的 Marshal 类
Imports System.Runtime.InteropServices '这里一定要有
Public Class Form1
Public Structure m_Point
Dim x As Integer
Dim y As Integer
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = 50
Dim ai() As Integer = {1, 2, 3, 4, 5}
Dim pi As IntPtr = GCHandle.Alloc(i, GCHandleType.Pinned).AddrOfPinnedObject() '取得整形变量的指针
Dim pai As IntPtr = GCHandle.Alloc(ai, GCHandleType.Pinned).AddrOfPinnedObject() '取得整形数组首地址指针
MsgBox(Marshal.ReadInt32(pi, 0)) '读回整形变量指针指向的值
MsgBox(Marshal.ReadInt32(pai, 0 * 4)) '读回数组的第一个元素
MsgBox(Marshal.ReadInt32(pai, 1 * 4)) '读回数组的第二个元素
MsgBox(Marshal.ReadInt32(pai, 2 * 4)) '读回数组的第三个元素
'-----下面是结构--------------------------
Dim m_p As New m_Point
m_p.x = 100
m_p.y = 50
Dim pm_p As IntPtr = GCHandle.Alloc(m_p, GCHandleType.Pinned).AddrOfPinnedObject() '取得结构首地址指针
MsgBox(Marshal.ReadInt32(pm_p, 0 * 4)) '读回结构的第一个值
MsgBox(Marshal.ReadInt32(pm_p, 1 * 4)) '读回结构的第二个值
End Sub
End Class
Sub 和()
Dim Arr, Dic As Object, i, j, k
Set Dic = CreateObject("Scripting.Dictionary")
Arr = Array(5, 7, 11, 13, 17, 19)
For i = 0 To UBound(Arr)
For j = 0 To UBound(Arr)
For k = 0 To UBound(Arr)
Dic(Arr(i) + Arr(j) + Arr(k)) = ""
Next k
Next j
Next i
MsgBox Dic.Count
Set Dic = Nothing
End Sub
结果为22种不同的和值。