字符串连接-mathematical statistics with applications

时间:2021-06-02 14:13:12
【文件属性】:
文件名称:字符串连接-mathematical statistics with applications
文件大小:13.45MB
文件格式:PDF
更新时间:2021-06-02 14:13:12
excel,VBA 5.4 命名参数 在前一练习中,输入过如下语句: iResult = Application.InputBox_("Please enter your favorite number:" , , , , , , ,1) 如果少输入一个逗号,当执行这条语句时就有可能出错。按照定义的位置传递参数具有 局限性。为了弥补这一缺陷, V B A支持命名参数。使用命名参数可以按照任意次序传递参数。 例如,通过使用命名参数,可以将前面的语句替换为: iResult = Application.InputBox("Please enter your favorite number:" ,Ty p e : = 1 ) 要使用命名参数,按照语法输入参数名,接着输入一个冒号和等号,在等号后面输入参 数值。当输入一条语句时,语句的语法会显示在 Q u i c k I n f o框中。通过在线帮助也可以找到语 句的语法。 如果没有显示快速信息,可选择“工具”、“选项”。选择“选项”对 话框中的“编辑器”选项卡,选中“自动显示快速信息”复选框。 5.5 字符串连接 如果需要合并字符串,那么可以使用字符串连接符 &。程序清单5 - 1说明了字符串连接符 的使用方法。 程序清单5-1 字符串连接 1: Sub stringstuff () 2: Dim sName As String 3: Dim sLongText As String 4 : 5: sName = InputBox("Please enter your name: ") 6 : 7: 'The following line of code combines Hello and the value 8: 'of sName so that it is displayed as a single string 9: 'in a message box. 10: MsgBox "Hello" & sName 11 : 12: sLongText = "This is an example of using string" 13: sLongText = sLongText & "concatenation to combine long" 14: sLongText = sLongText & "strings. "& vbNewLine 15: sLongText = sLongText & "The vbNewLine constant allows you" 16: sLongText = sLongText & "to add line breaks to your strings. " 17: MsgBox sLongText 18: End Sub 图5 - 6显示了代码行MsgBox sLongTe x t显示字符串的结果。通过使用字符串连接符,可以 48使用中文Excel 2000编程 2 4学时教程

网友评论