vb文本框输出时多行显示 要保留每一行 点击一下“输入” 生成一行
就像图片那样要求每输入一次设备信息单击“输入”就可以产生“设备资料”。然后还要注意自动换行(“设备类别”“是否进口”要注意是随机选择)另外还有那个共输入多少台。求各位大大...
就像图片那样 要求每输入一次设备信息单击 “输入 ”就可以产生“设备资料”。然后还要注意自动换行(“设备类别” “是否进口”要注意是随机选择)另外还有那个共输入多少台。 求各位大大给下代码吧 愁死我了。。。。。。。。。。。。。。。。。。。
展开
2个回答
展开全部
把代码复制进文本,后缀名修改为"1.FRM"
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "设备情况输入"
ClientHeight = 3255
ClientLeft = 45
ClientTop = 435
ClientWidth = 7200
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3255
ScaleWidth = 7200
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "输入"
Height = 495
Left = 4680
TabIndex = 22
Top = 1800
Width = 1215
End
Begin VB.TextBox Text4
Height = 270
Left = 3720
TabIndex = 14
Top = 840
Width = 495
End
Begin VB.TextBox Text3
Height = 1935
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 11
Top = 1200
Width = 4455
End
Begin VB.Frame Frame2
Caption = "设备类别"
Height = 855
Left = 4680
TabIndex = 10
Top = 840
Width = 2415
Begin VB.CheckBox Check1
Caption = "冲压"
Height = 255
Index = 5
Left = 1560
TabIndex = 21
Top = 480
Width = 735
End
Begin VB.CheckBox Check1
Caption = "普通"
Height = 255
Index = 4
Left = 840
TabIndex = 20
Top = 480
Width = 735
End
Begin VB.CheckBox Check1
Caption = "自控"
Height = 255
Index = 3
Left = 120
TabIndex = 19
Top = 480
Width = 735
End
Begin VB.CheckBox Check1
Caption = "精密"
Height = 255
Index = 2
Left = 1560
TabIndex = 18
Top = 240
Width = 735
End
Begin VB.CheckBox Check1
Caption = "车床"
Height = 255
Index = 1
Left = 840
TabIndex = 17
Top = 240
Width = 735
End
Begin VB.CheckBox Check1
Caption = "铳床"
Height = 255
Index = 0
Left = 120
TabIndex = 16
Top = 240
Width = 735
End
End
Begin VB.Frame Frame1
Caption = "是否进口"
Height = 615
Left = 4680
TabIndex = 8
Top = 120
Width = 1695
Begin VB.OptionButton Option1
Caption = "国产"
Height = 300
Index = 1
Left = 840
TabIndex = 23
Top = 240
Width = 735
End
Begin VB.OptionButton Option1
Caption = "进口"
Height = 300
Index = 0
Left = 120
TabIndex = 9
Top = 240
Value = -1 'True
Width = 735
End
End
Begin VB.TextBox Text2
Height = 270
Left = 3360
TabIndex = 7
Top = 120
Width = 1215
End
Begin VB.ComboBox Combo2
Height = 300
Left = 3360
Style = 2 'Dropdown List
TabIndex = 5
Top = 480
Width = 1215
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1080
Style = 2 'Dropdown List
TabIndex = 3
Top = 480
Width = 1215
End
Begin VB.TextBox Text1
Height = 270
Left = 1080
TabIndex = 1
Top = 120
Width = 1215
End
Begin VB.Label Label7
Caption = "台"
Height = 255
Left = 4320
TabIndex = 15
Top = 840
Width = 255
End
Begin VB.Label Label6
Caption = "共输入"
Height = 255
Left = 3120
TabIndex = 13
Top = 840
Width = 615
End
Begin VB.Label Label5
Caption = "设备资料:"
Height = 255
Left = 120
TabIndex = 12
Top = 840
Width = 975
End
Begin VB.Label Label4
Caption = "设备名称:"
Height = 255
Left = 2400
TabIndex = 6
Top = 120
Width = 975
End
Begin VB.Label Label3
Caption = "生产地:"
Height = 255
Left = 2400
TabIndex = 4
Top = 480
Width = 975
End
Begin VB.Label Label2
Caption = "进口国家:"
Height = 255
Left = 120
TabIndex = 2
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "设备编号:"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim IndexOP As Integer, IndexCH(5) As Boolean
Private Sub Check1_Click(Index As Integer)
IndexCH(Index) = Not IndexCH(Index)
End Sub
Private Sub Command1_Click()
Dim I, X
For I = 0 To 5
X = X & IIf(IndexCH(I) = True, " " & Check1(I).Caption, "")
Next I
Text3.Text = Text3.Text & " " & Text1.Text & Text2.Text & " " & IIf(IndexOP = 0, "进口", "国产") & " " & _
IIf(IndexOP = 0, Combo1.Text, Combo2.Text) & X & vbCrLf
Text4.Text = Val(Text4.Text) + 1
End Sub
Private Sub Form_Load()
Combo1.AddItem "美国"
Combo1.AddItem "日本"
Combo1.Text = "美国"
Combo2.AddItem "上海"
Combo2.AddItem "沈阳"
Combo2.Text = "沈阳"
End Sub
Private Sub Option1_Click(Index As Integer)
IndexOP = Index
End Sub
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "设备情况输入"
ClientHeight = 3255
ClientLeft = 45
ClientTop = 435
ClientWidth = 7200
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3255
ScaleWidth = 7200
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "输入"
Height = 495
Left = 4680
TabIndex = 22
Top = 1800
Width = 1215
End
Begin VB.TextBox Text4
Height = 270
Left = 3720
TabIndex = 14
Top = 840
Width = 495
End
Begin VB.TextBox Text3
Height = 1935
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 11
Top = 1200
Width = 4455
End
Begin VB.Frame Frame2
Caption = "设备类别"
Height = 855
Left = 4680
TabIndex = 10
Top = 840
Width = 2415
Begin VB.CheckBox Check1
Caption = "冲压"
Height = 255
Index = 5
Left = 1560
TabIndex = 21
Top = 480
Width = 735
End
Begin VB.CheckBox Check1
Caption = "普通"
Height = 255
Index = 4
Left = 840
TabIndex = 20
Top = 480
Width = 735
End
Begin VB.CheckBox Check1
Caption = "自控"
Height = 255
Index = 3
Left = 120
TabIndex = 19
Top = 480
Width = 735
End
Begin VB.CheckBox Check1
Caption = "精密"
Height = 255
Index = 2
Left = 1560
TabIndex = 18
Top = 240
Width = 735
End
Begin VB.CheckBox Check1
Caption = "车床"
Height = 255
Index = 1
Left = 840
TabIndex = 17
Top = 240
Width = 735
End
Begin VB.CheckBox Check1
Caption = "铳床"
Height = 255
Index = 0
Left = 120
TabIndex = 16
Top = 240
Width = 735
End
End
Begin VB.Frame Frame1
Caption = "是否进口"
Height = 615
Left = 4680
TabIndex = 8
Top = 120
Width = 1695
Begin VB.OptionButton Option1
Caption = "国产"
Height = 300
Index = 1
Left = 840
TabIndex = 23
Top = 240
Width = 735
End
Begin VB.OptionButton Option1
Caption = "进口"
Height = 300
Index = 0
Left = 120
TabIndex = 9
Top = 240
Value = -1 'True
Width = 735
End
End
Begin VB.TextBox Text2
Height = 270
Left = 3360
TabIndex = 7
Top = 120
Width = 1215
End
Begin VB.ComboBox Combo2
Height = 300
Left = 3360
Style = 2 'Dropdown List
TabIndex = 5
Top = 480
Width = 1215
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1080
Style = 2 'Dropdown List
TabIndex = 3
Top = 480
Width = 1215
End
Begin VB.TextBox Text1
Height = 270
Left = 1080
TabIndex = 1
Top = 120
Width = 1215
End
Begin VB.Label Label7
Caption = "台"
Height = 255
Left = 4320
TabIndex = 15
Top = 840
Width = 255
End
Begin VB.Label Label6
Caption = "共输入"
Height = 255
Left = 3120
TabIndex = 13
Top = 840
Width = 615
End
Begin VB.Label Label5
Caption = "设备资料:"
Height = 255
Left = 120
TabIndex = 12
Top = 840
Width = 975
End
Begin VB.Label Label4
Caption = "设备名称:"
Height = 255
Left = 2400
TabIndex = 6
Top = 120
Width = 975
End
Begin VB.Label Label3
Caption = "生产地:"
Height = 255
Left = 2400
TabIndex = 4
Top = 480
Width = 975
End
Begin VB.Label Label2
Caption = "进口国家:"
Height = 255
Left = 120
TabIndex = 2
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "设备编号:"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim IndexOP As Integer, IndexCH(5) As Boolean
Private Sub Check1_Click(Index As Integer)
IndexCH(Index) = Not IndexCH(Index)
End Sub
Private Sub Command1_Click()
Dim I, X
For I = 0 To 5
X = X & IIf(IndexCH(I) = True, " " & Check1(I).Caption, "")
Next I
Text3.Text = Text3.Text & " " & Text1.Text & Text2.Text & " " & IIf(IndexOP = 0, "进口", "国产") & " " & _
IIf(IndexOP = 0, Combo1.Text, Combo2.Text) & X & vbCrLf
Text4.Text = Val(Text4.Text) + 1
End Sub
Private Sub Form_Load()
Combo1.AddItem "美国"
Combo1.AddItem "日本"
Combo1.Text = "美国"
Combo2.AddItem "上海"
Combo2.AddItem "沈阳"
Combo2.Text = "沈阳"
End Sub
Private Sub Option1_Click(Index As Integer)
IndexOP = Index
End Sub
追问
谢谢你的帮助
展开全部
意思不是很明白,大致思路:
用变量分别取出文本框和列表框的值,是否进口那的单选按钮做判断,然后取值,设备类别里面的6个内容也分别判断是否选中,然后取值。
1、上面的数据都取出后,合并到一起:示例 a & " " & b & " " & c,就是将a、b、c三个字符合并成,并在中间加上空格(注意:a、b、c均为字符型变量)
2、自动换行使用vbcrlf,示例:text1.text = "abc" & vbcrlf & "123" (使用的前提是要将文本框的多行属性multiline设置为true)
有问题的话,单独鸽子我吧(QQ43595076)
用变量分别取出文本框和列表框的值,是否进口那的单选按钮做判断,然后取值,设备类别里面的6个内容也分别判断是否选中,然后取值。
1、上面的数据都取出后,合并到一起:示例 a & " " & b & " " & c,就是将a、b、c三个字符合并成,并在中间加上空格(注意:a、b、c均为字符型变量)
2、自动换行使用vbcrlf,示例:text1.text = "abc" & vbcrlf & "123" (使用的前提是要将文本框的多行属性multiline设置为true)
有问题的话,单独鸽子我吧(QQ43595076)
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询