VBA获取文本框以显示文本和变量

时间:2016-05-25 17:02:18

标签: vba

我正在使用Word 2010并尝试使用文本框显示变量,然后在变量后面显示一些文本。

我可以编码反之亦然:

Private Sub OverallScore_Click()

OverallTotalScore = Attendance + DiligenceTotalScore + QualityTotalScore + SafetyTotalScore + TeamworkTotalScore + SkillsTotalScore

Select Case OverallTotalScore
    Case 0 To 69
        OverallScoreTextBox.Text = ("Rate increase $0.20 " & OverallTotalScore)
    Case 70 To 77
        OverallScoreTextBox.Text = ("Rate increase $0.25 " & OverallTotalScore)
    Case 78 To 84
        OverallScoreTextBox.Text = ("Rate increase $0.35 " & OverallTotalScore)
    Case 85 To 92
        OverallScoreTextBox.Text = ("Rate increase $0.45 " & OverallTotalScore)
    Case 93 To 100
        OverallScoreTextBox.Text = ("Rate increase $0.50 " & OverallTotalScore)
    End Select 

但是,我希望它首先显示为分数,然后显示文本

1 个答案:

答案 0 :(得分:0)

使用此

Private Sub OverallScore_Click()

OverallTotalScore = Attendance + DiligenceTotalScore + QualityTotalScore + SafetyTotalScore + TeamworkTotalScore + SkillsTotalScore

Select Case OverallTotalScore
    Case 0 To 69
        OverallScoreTextBox.Text = (OverallTotalScore & " Rate increase $0.20")
    Case 70 To 77
        OverallScoreTextBox.Text = (OverallTotalScore & " Rate increase $0.25")
    Case 78 To 84
        OverallScoreTextBox.Text = (OverallTotalScore & " Rate increase $0.35")
    Case 85 To 92
        OverallScoreTextBox.Text = (OverallTotalScore & " Rate increase $0.45")
    Case 93 To 100
        OverallScoreTextBox.Text = (OverallTotalScore & " Rate increase $0.50")
    End Select 
End sub

&用于构建你的字符串(通过连接它们),所以你可以轻松地切换两边的字符串