散列对VB中的变量有什么作用? [英] What does a hash do to a variable in VB?

查看:12
本文介绍了散列对VB中的变量有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将一个 VB6 程序重构为 C#,并坚持理解以下几行:

I have to refactor a VB6 program to C# and am stuck at understanding the following lines:

Set myFileSystemObject = New FileSystemObject
Set myTextStream = myFileSystemObject.OpenTextFile("myTextFile.txt")
Open sPrinterPort For Output As iFileNumber
Print #iFileNumber, myTextStream.ReadAll
Close #iFileNumber

我确实知道一般情况,但由于我不习惯 VB 语法,所以我想知道具体是什么

I do know what's generally happening, but as I'm not used to the VB syntax, I'd like to know exactly what

Print #iFileNumber, myTextStream.ReadAll

确实如此.更具体地说,iFileNumber 前面的 # 的作用.为什么会在那里?变量本身不足以在流上打印吗?

does. And more specifically, what the # in front of iFileNumber does. Why is it there? Wouldn't the variable itself suffice to print on the stream?

这只是为了准确理解代码中发生的事情.

This is merely for understanding exactly what's happening in the code.

推荐答案

Print #iFileNumber, myTextStream.ReadAllReadAll返回的字符串打印到编号打开的文件中iFileNumber(又因为语句后面没有分号,所以最后还加上了vbNewLine.)

Print #iFileNumber, myTextStream.ReadAll prints the string returned by ReadAll into the file opened by number iFileNumber (and because there is no semicolon after the statement, it also adds vbNewLine in the end.)

#(表示数字")自古以来就存在.VB6 只是支持它.它在执行方面没有任何作用.它用于帮助提高可读性并使语言更自然.大声说出来:

The # (for "number") is there since the old times. VB6 just supports it. It does nothing execution wise. It used to assist readability and make the language more natural-like. Speak out loud:

Open "1.txt" For Input As 1

对比

Open "1.txt" For Input As #1

这篇关于散列对VB中的变量有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆