前提:使用者输入的是:纯中文 or 纯英文我要将使用者输入的文字显示出来,根据字数的多少,来设置字体的大小。
Dim str As String = Tables("表A").Current("名称")
Dim lb2 As WinForm.Label = Forms("表A").Controls("lb2") '显示名称
If str.Length >= 15 Then
lb2.Font = new Font("微软雅黑",60,FontStyle.Bold)
ElseIf str.Length >= 13 AndAlso str.Length <= 14 Then
lb2.Font = new Font("微软雅黑",70,FontStyle.Bold)
Else
lb2.Font = new Font("微软雅黑",80,FontStyle.Bold)
End If
问题:不管是中文字符还是英文字符,在计算长度的时候,均为1。
所以当使用输入英文时,虽然字数很多,但实际占用空间不大,需要放大显示。
是否可以判断输入的是中文还是英文,我可以分开来控制大小?
或者用别的方法,来控制文本框大小?
例如:
Dim str1 As String = "中华人民共和国" 'str1.Length = 7
Dim str2 As String = "Chinese people" 'str2.Length = 14