给你个思路。
1、把文章读取到内存A1,A1数组为vbcrlf
Public Sub Load_Txt(ByVal Txt_Filename, A1)
Dim by As String
Open Txt_Filename For Binary As #1
by = Space(LOF(1))
Get #2, , by
A1 = Split(by, vbCrLf)
DoEvents
Close #1
End Sub
2、转换为不空段落数组A2
dim a2
index1=1
redim a2(1)
for i= 0 to ubound(a1)
if a1(i)<>"" then
a2(0)=index1'a2(0)记录不空段落总数,a2(1-index1)记录对应的index1个段落
redim preserve a2(index1)
a2(index1)=index1
index1=index1+1
end if
next
3、生成1-index之间的3个不同随机数
Randomize
for i=1 to 3
rnd1=int(rnd(0)*index1+0.005)'产生1-index之间的随机数
temp=a2(index1):a2(index1)=a2(rend1):a2(rnd1)=temp:将产生的随机数放到最后,为下次index-1个随机数不重复做准备
text1(i)=a2(index1)'text1(1-3)为需要随机显示的3个不同段落
index=index-1
next