喜欢“text1.text = A + B”并列 [英] like "text1.text=A+B" to juxtapose

查看:145
本文介绍了喜欢“text1.text = A + B”并列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 私有  Sub  Command1_Click()
Dim b 作为 整数,a1,a2 作为 整数
Dim c 作为 整数
' ****************************
对于 b = 0 2
如果 Check1(b).Value = 1 然后
c = c + Check1(b)
结束 如果
下一步
' ************************* **
对于 b = 0 2

如果 c> = < span class =code-digit> 2 然后
如果 Check1( b).Index = 0 然后
a1 = 59
ElseIf Check1(b).Index = 1 然后
a1 = 60
ElseIf Check1(b).Index = 2 然后
a1 = 61
否则
结束 如果
' *** ************************************
如果 Check1(b).Value = 1 那么
Dim strText() As String
ReDim 保留strText( 0 c) As String
MsgBox c
对于 i = 0 c
strText(i)= Check1 (b).Caption
Text1.Text = strText(i)& +& a1
下一步 i
其他
结束 如果
' ******************************************
ElseIf c< 2 然后
' < span class =code-comment> ***************************************** *
如果 Check1(b).Index = 0 然后
a2 = 59
ElseIf Check1(b).Index = 1 然后
a2 = 60
ElseIf Check1(b).Index = 2 然后
a2 = 61
否则
结束 如果
' ******************************** **********
如果 Check1(b).Value = 1 那么
ReDim 保留strText( 0 c)作为 字符串
对于 i = 0 c
strText(i)= Check1(b).Caption
Text1.Text = strText(i)& +& a2
下一步 i
其他
结束 如果
结束 如果
下一步
' ************ *
结束 Sub



像text1.text = A + B并列

解决方案

看起来正确(双引号除外)

如果使用数字并且想要添加,则使用+

如果要连接两个字符串,请使用&



text1。 text = A + B'A = 1,B = 2,Text1.text将显示3

text1.text = A&B'A = 1,B = 2,Text1.text将显示12

Private Sub Command1_Click()
Dim b As Integer, a1, a2 As Integer
Dim c As Integer
'****************************
For b = 0 To 2
  If Check1(b).Value = 1 Then
     c = c + Check1(b)
  End If
 Next
'***************************
For b = 0 To 2

If c >= 2 Then
If Check1(b).Index = 0 Then
a1 = 59
ElseIf Check1(b).Index = 1 Then
a1 = 60
ElseIf Check1(b).Index = 2 Then
a1 = 61
Else
End If
'***************************************
If Check1(b).Value = 1 Then
Dim strText() As String
ReDim Preserve strText(0 To c) As String
     MsgBox c
    For i = 0 To c
         strText(i) = Check1(b).Caption
         Text1.Text = strText(i) & "+" & a1
      Next i
  Else
End If
'******************************************
ElseIf c < 2 Then
'******************************************
If Check1(b).Index = 0 Then
   a2 = 59
ElseIf Check1(b).Index = 1 Then
   a2 = 60
ElseIf Check1(b).Index = 2 Then
   a2 = 61
 Else
End If
'******************************************
If Check1(b).Value = 1 Then
ReDim Preserve strText(0 To c) As String
For i = 0 To c
    strText(i) = Check1(b).Caption
    Text1.Text = strText(i) & "+" & a2
    Next i
   Else
  End If
 End If
Next
'*********************************************
End Sub


like "text1.text=A+B" to juxtapose

解决方案

That looks correct (except the double quotes)
If working with numbers and you want to add, you use the +
If you want to concatenate two strings, use &

text1.text = A + B ' A=1, B=2, Text1.text will display 3
text1.text = A & B ' A=1, B=2, Text1.text will display 12


这篇关于喜欢“text1.text = A + B”并列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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