VB 常用代码
发布时间:2020-12-16 22:58:11 所属栏目:大数据 来源:网络整理
导读:1. 打开文件对话框 工程--部件--Microsoft Common Dialog Control 6.0 ImportDialog.InitDir = App.Path '默认打开目录 ImportDialog.Filter = "文本文件(*.txt)|*.txt|数据文件(*.dat)|*.dat" '文件过滤器 ImportDialog.ShowOpen '打开对话框 If Not Len(Im
1. 打开文件对话框 工程-->部件-->Microsoft Common Dialog Control 6.0 ImportDialog.InitDir = App.Path '默认打开目录 ImportDialog.Filter = "文本文件(*.txt)|*.txt|数据文件(*.dat)|*.dat" '文件过滤器 ImportDialog.ShowOpen '打开对话框 If Not Len(ImportDialog.FileName) = 0 Then Open ImportDialog.FileName For Input As #1 Do Until EOF(1) Line Input #1,newURL Loop Close #1 End If 2.回车换行符 vbCrLf 是VB回车换行符 chr(10) & chr(13) 用 vbCrLf 会空出一行,用chr(13)就正好 3. 数组长度 用ubound()函数知道数组的上限,lbound()函数知道数组的下限,ubound()-lbound()+1就是数组元素的个数 例如: dim a(10) as long dim nLen as long nLen = ubound(a) - lbound(a) + 1 '这里上限是10,下限是0,结果是11 4. WebBrowser控件下载进度条 进度条ProgressBar控件:工程-部件-MicroSoft Windows Common Controls 6.0 Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long,ByVal ProgressMax As Long) If ProgressMax = 0 Then Exit Sub ProgressBar1.Max = ProgressMax If Progress <> -1 And Progress <= ProgressMax Then ProgressBar1.Value = Progress End If End Sub (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |