一组很长的数(700多个,在一个txt文件里),要赋给一个数组,整体赋值的格式是怎么样的?是a(0-700)=(5,8,3,……)吗?
解决方案 »
- 如何在VB中改变SSTab和checkbox控件的颜色,使它与窗体的背景颜色相同
- 急问vb中的基础问题!高手帮忙!
- [组件代码共享]可逆加密,支持中文,支持密钥,支持ASP,加密后的密文每次都不同,且可随意改变算法
- 着急!用setup factory6做好打包后在新的系统安装支运行出现“数据绑定DLL,‘VB5DB.DLL’不能加载”?怎么解决?
- 关于commondialog的问题
- 如何用代码代替网页中点击标签事件(如何寻找这标签)?
- 求解:算法题(2)真的好难啊
- 请问项目高手,vb编译的执行文件EXE太大能否分开几个库放置吗,像PB的PBD那样?
- 誰能告訴我.vb6.0自帶的Crystal report(版本4.6.1.0)的注冊碼.
- 请懂得DirectX的高手进来
- 怎样才能让 自己写的控件 在vb的ide环境下 显示自己的index值
- 三联据打印完了没法撕怎么办呀
dim s as string
dim t as long ...获取700个数到s,此时s="5,8,3,…"a=split(s,",")
for t=0 to ubound(a)
debug.print a(t),
next5 8 3 ...
Split函数的参数为一个字符串、一个分隔符(可选)、返回的子字符串个数、以及比较方法。该函数返回一个基于零的(zero-based)数组,子字符串为数组元素。下面的代码将上例产生的字符串作为Split函数的参数,Split函数将恢复出一个数组。 Dim strTest As String
Dim vntSplit As VariantstrTest = "1|2|3|4|5"
vntSplit = Split(strTest, "|")
MsgBox vntSplit(0)
open "D:\txt.txt" for input as #1
do while not eof(1)
line input #1,str
a(i) = val(str)
i= i +1
loop
close #1
你告诉我你用什么方式存储数据的?再具体分析怎么样读取文件,给数组赋值
* D:\MATLAB6.5.1\extern\include\tmwtypes.h
*/
const int BL = 751;
const long double B[751] = {
-1.013673924802e-006,-2.258803187446e-005,-1.589547818038e-005,1.660993037745e-005,
3.224853521096e-005,3.599892326701e-006,-3.647061462228e-005,-3.118014867772e-005,……
而且数很多,700多个,不会读取,不知道怎么赋给我现在vb程序里的数组,不知道你有什么高见
改成:
dim a() as double
dim t as long
dim s as strings="-1.013673924802e-006,-2.258803187446e-005,-1.589547818038e-005,1.660993037745e-005,3.224853521096e-005,3.599892326701e-006,-3.647061462228e-005,-3.118014867772e-005"
a()=split(s,",")不知道类型转换的时候会不会出错。,,会的话就的还用个string数组来中转
dim StrVal as string
dim Lng_s as long
dim Lng_e as long
dim s as long
s= 1
open " D:\MATLAB6.5.1\extern\include\tmwtypes.h" for binary as #1
do while not eof(1)
get #1,s,str
if str = chr("{") then Lng_s = s
if str = chr("}") then Lng_e = s
s= seek(1)
loop
close #1 这里麻烦点容易理解先关闭再打开 s= Lng_s
open " D:\MATLAB6.5.1\extern\include\tmwtypes.h" for binary as #2
if s<= Lng_e then
get #1,s,str
StrVal= StrVal & Str
s =seek(1)
end if
close #2
dim Val() as string
val= split(StrVal,",")数组val就是你要的值!!你看看是不是,或许有点字节偏差,你自己调试调试
if str = chr("}") then Lng_e = s
有函数错误哦,
if str = "{" then Lng_s = s
if str = "}" then Lng_e = s
请更正
改为dim str as string * 1
呵呵,不好意思哦