标题:[求助]刚学Vb,就有问题了.
只看楼主
akimoto
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-6-2
 问题点数:0 回复次数:4 
[求助]刚学Vb,就有问题了.

如图所示,在 txt 里每个数都是用逗号隔开的,但到了最后一个数也是这样, 请问有什么方法可以把最后的一个数替换成句号呢..? 刚学Vb几天,不懂,请指教下.. 代码: Private Sub cmdend_Click() Unload Me End End Sub

Private Sub cmdjs_Click() Dim x As Integer Dim y As Integer Dim z As Integer

If (txtxj.Text <> "" Or txtgj.Text <> "" Or txtmj.Text <> "") Then txtxj.Text = "" txtgj.Text = "" txtmj.Text = "" For x = 0 To 100 For y = 0 To 100 For z = 0 To 100 If (x + y + z = 100 And (0.5 * x + 2 * y + 3 * z) = 100) Then txtxj.Text = txtxj.Text & x & "," txtgj.Text = txtgj.Text & y & "," txtmj.Text = txtmj.Text & z & "," End If Next z Next y Next x

Else

For x = 0 To 100 For y = 0 To 100 For z = 0 To 100 If (x + y + z = 100 And (0.5 * x + 2 * y + 3 * z) = 100) Then txtxj.Text = txtxj.Text & x & "," txtgj.Text = txtgj.Text & y & "," txtmj.Text = txtmj.Text & z & "," End If Next z Next y Next x

End If

End Sub

Private Sub Form_DblClick() txtxj.Text = "" txtgj.Text = "" txtmj.Text = "" cmdjs.SetFocus End Sub

[此贴子已经被作者于2005-8-4 13:49:25编辑过]

搜索更多相关主题的帖子: 如图所示 
2005-08-04 13:43
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
得分:0 
请把代码贴出来。
PS:这好像是 OS 系统。
2005-08-04 13:47
akimoto
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-6-2
得分:0 
贴了..

2005-08-04 13:49
slore
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1108
专家分:0
注 册:2005-7-1
得分:0 
Text1 = Replace(Text1, Right(Text1, 1), ".")

快上课了……
2005-08-04 18:36
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
得分:0 
你在 Next x 语句下面写:

If Right(txtxj.Text,1) = "," Then txtxj.Text = Left(txtxj.Text, Len(txtxj.Text) - 1)
If Right(txtgj.Text,1) = "," Then txtgj.Text = Left(txtgj.Text, Len(txtgj.Text) - 1)
If Right(txtmj.Text,1) = "," Then txtmj.Text = Left(txtmj.Text, Len(txtmj.Text) - 1)
2005-08-04 21:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-24321-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.341906 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved