VB程序设计
一.设计一个字符大小写转换程序。当在文本框1中输入大写字母,在文本框2中同时显示其小写字母;当在文本框1中输入小写字母,在文本框2中同时显示其大写字母;当输入其他字符,则...
一. 设计一个字符大小写转换程序。当在文本框1中输入大写字母,在文本框2中同时显示其小写字母;当在文本框1中输入小写字母,在文本框2中同时显示其大写字母;当输入其他字符,则在文本框2中原样输出。
二. 设计“健康秤”程序,要求:1将两个文本框的文字对齐方式均设置为右对齐,最多接受3个字符;2.两个文本框均不接收非数字键;3.单击“健康状况”按钮后,根据计算公式将相应提示信息通过标签显示在按钮下面。
3. 计算公式:标准体重=身高-105
4. 体重高于标准体重的1.1倍为偏胖,提示“偏胖,加强锻炼,注意节食”
5. 体重低于标准体重的0.9为偏瘦,提示“偏瘦,增加营养’
6. 其他为正常,提示“正常,继续保持”。
江湖救急啊!!!感谢!!! 展开
二. 设计“健康秤”程序,要求:1将两个文本框的文字对齐方式均设置为右对齐,最多接受3个字符;2.两个文本框均不接收非数字键;3.单击“健康状况”按钮后,根据计算公式将相应提示信息通过标签显示在按钮下面。
3. 计算公式:标准体重=身高-105
4. 体重高于标准体重的1.1倍为偏胖,提示“偏胖,加强锻炼,注意节食”
5. 体重低于标准体重的0.9为偏瘦,提示“偏瘦,增加营养’
6. 其他为正常,提示“正常,继续保持”。
江湖救急啊!!!感谢!!! 展开
2个回答
展开全部
'题一:
'设置两个文本框text1和text2,调整好它们的大小(程序不再对它们的大小和位置属性进行设置),
'然后设置它们的multiline属性为ture,代码为:
Option Explicit
Private Sub Form_Load()
form1.caption="第一题"
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 65 And KeyAscii <= 90 Then
Text2.Text = Text2.Text + Chr(KeyAscii + 32)
ElseIf KeyAscii >= 97 And KeyAscii <= 123 Then
Text2.Text = Text2.Text + Chr(KeyAscii - 32)
Else
Text2.Text = Text2.Text + Chr(KeyAscii)
End If
End Sub
'题二:
'设置两个文本框text1和text2,调整好它们的大小,
'放一个command1,一个label1,并调整好位置和大小。
'(程序不再对各控件的大小和位置属性进行设置)
'代码为:
Option Explicit
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then Exit Sub
Dim A As Single
A = Val(Text1.Text) / (Val(Text2.Text) - 105)
If A > 1.1 Then
Label1.Caption = "偏胖,加强锻炼,注意节食"
ElseIf A < 0.9 Then
Label1.Caption = "偏瘦,增加营养"
Else
Label1.Caption = "正常,继续保持"
End If
End Sub
Private Sub Form_Load()
Form1.Caption = "第二题"
Text1.Text = ""
Text1.MaxLength = 3
Text1.Alignment = 1
Text2.Text = ""
Text2.Alignment = 1
Text2.MaxLength = 3
Command1.Caption = "健康状况"
Label1.Caption = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
'设置两个文本框text1和text2,调整好它们的大小(程序不再对它们的大小和位置属性进行设置),
'然后设置它们的multiline属性为ture,代码为:
Option Explicit
Private Sub Form_Load()
form1.caption="第一题"
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 65 And KeyAscii <= 90 Then
Text2.Text = Text2.Text + Chr(KeyAscii + 32)
ElseIf KeyAscii >= 97 And KeyAscii <= 123 Then
Text2.Text = Text2.Text + Chr(KeyAscii - 32)
Else
Text2.Text = Text2.Text + Chr(KeyAscii)
End If
End Sub
'题二:
'设置两个文本框text1和text2,调整好它们的大小,
'放一个command1,一个label1,并调整好位置和大小。
'(程序不再对各控件的大小和位置属性进行设置)
'代码为:
Option Explicit
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then Exit Sub
Dim A As Single
A = Val(Text1.Text) / (Val(Text2.Text) - 105)
If A > 1.1 Then
Label1.Caption = "偏胖,加强锻炼,注意节食"
ElseIf A < 0.9 Then
Label1.Caption = "偏瘦,增加营养"
Else
Label1.Caption = "正常,继续保持"
End If
End Sub
Private Sub Form_Load()
Form1.Caption = "第二题"
Text1.Text = ""
Text1.MaxLength = 3
Text1.Alignment = 1
Text2.Text = ""
Text2.Alignment = 1
Text2.MaxLength = 3
Command1.Caption = "健康状况"
Label1.Caption = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
2009-03-08
展开全部
第一题
Private Sub Text1_KeyPress(KeyAscii As Integer)
If 65 <= KeyAscii And KeyAscii <= 90 Then Text2.Text = Text2.Text & LCase(Chr(KeyAscii))
If 97 <= KeyAscii And KeyAscii <= 122 Then Text2.Text = Text2.Text & UCase(Chr(KeyAscii))
End Sub
第二题
Private Sub Command1_Click()
身高 = Text1.Text
体重 = Text2.Text
标准体重 = 身高 - 105
Select Case Val(体重) / 标准体重
Case Is > 1.1
Label1.Caption = "偏胖,加强锻炼,注意节食"
Case Is < 0.9
Label1.Caption = "偏瘦,增加营养"
Case Else
Label1.Caption = "正常"
End Select
End Sub
Private Sub Form_Load()
Text1.MaxLength = 4
Text2.MaxLength = 4
Command1.Caption = "健康状况"
Text1.Text = "身高"
Text2.Text = "体重"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If 65 <= KeyAscii And KeyAscii <= 90 Then Text2.Text = Text2.Text & LCase(Chr(KeyAscii))
If 97 <= KeyAscii And KeyAscii <= 122 Then Text2.Text = Text2.Text & UCase(Chr(KeyAscii))
End Sub
第二题
Private Sub Command1_Click()
身高 = Text1.Text
体重 = Text2.Text
标准体重 = 身高 - 105
Select Case Val(体重) / 标准体重
Case Is > 1.1
Label1.Caption = "偏胖,加强锻炼,注意节食"
Case Is < 0.9
Label1.Caption = "偏瘦,增加营养"
Case Else
Label1.Caption = "正常"
End Select
End Sub
Private Sub Form_Load()
Text1.MaxLength = 4
Text2.MaxLength = 4
Command1.Caption = "健康状况"
Text1.Text = "身高"
Text2.Text = "体重"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询