停止在Visual Basic Express中观看 [英] stop Watch in Visual Basic Express

查看:87
本文介绍了停止在Visual Basic Express中观看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在Visual Basic Express中制作的秒表。

当秒表停止时,它会在消息框中显示该图。



我想要它做的是将可以输入文本框的数字乘以已经显示在消息框中的时间数字。



假设您在文本框中输入2.45并且录制的时间是5.34然后在消息框中它将在消息框中显示答案2.45(文本框)* 5.34(秒表上记录的时间)= 13.083。



这是我到目前为止的代码:

请帮我完成这个,感谢Paul







 公共  Form1 

私有 Sub Timer1_Tick ( ByVal 发​​件人作为系统。对象 ByVal e As System.EventArgs)句柄 Timer1.Tick
Label1.Text = Label1.Text + 0 01
结束 Sub

私有 Sub Button1_Click( ByVal 发​​件人作为系统。对象 ByVal e As System.EventArgs)句柄 Button1.Click
Timer1.Enabled = True
结束 Sub

私人 Sub Button2_Click( ByVal sender As 系统。对象 ByVal e 作为系统.EventArgs)句柄 Button2.Click
Timer1.Enabled = False
MsgBox( Label1.Text)
结束 Sub

私有 Sub Button3_Click( ByVal sender 作为系统。对象 ByVal e As System.EventArgs)句柄 Button3.Click
Timer1.Enabled = False
Label1.Text = 0 0
End Sub

私有 Sub Form1_Load( ByVal sender As System。对象 ByVal e 作为 System.EventArgs)句柄 MyBase .Load

结束 Sub

私有 Sub MaskedTextBox1_MaskInputRejected( ByVal sender As System。 Object ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs)

End Sub
结束

解决方案

你好



如果你认为TextBox1.Text和Label1.Text总是包含一个数字那么只需乘以这两个值并显示结果:



 私有 < span class =code-keyword> Sub  Button2_Click( ByVal  sender  As  System。< span class =code-keyword> Object , ByVal  e  As  System.EventArgs) 句柄 Button2.Click 
Timer1.Enabled = False

< span class =code-keyword> Di m 结果作为 字符串
result = TextBox1.Text * Label1.Text

MsgBox(结果)
结束 Sub





如果文本值可能是其他东西,您可能需要先将它们转换为数字:



 私有  Sub  Button2_Click( ByVal  sender  As  System。 Object  ByVal  e  As  System.EventArgs)句柄 Button2.Click 
Timer1 .Enabled = False

Dim value 作为 Double
Dim 结果作为 字符串

如果 Double .TryParse(TextBox1.Text,value)然后
' TextBox1.Text是一个数字
result = value * Label1.Text
结束 如果

MsgBox(结果)
结束 Sub









Valery。


感谢Valery提供我需要的正确帮助。保罗

This is my stop watch I made in Visual Basic Express.
When the stop watch stops it displays the figure in the Message Box.

What I want it to do is Multiply the figure which can be entered into the text box by the time figure recorded which is already displayed in the message box.

Say you enter 2.45 in Text box and time recorded is 5.34 then in the message box it would display the answer which is 2.45 (text Box) * 5.34 (time recorded on stop watch) = 13.083 in the message box.

This is the code I have got so far :
Please help me finish this off, Thanks From Paul



Public Class Form1

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = Label1.Text + 0.01
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Enabled = False
        MsgBox(Label1.Text)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Timer1.Enabled = False
        Label1.Text = 0.0
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub MaskedTextBox1_MaskInputRejected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs)

    End Sub
End Class

解决方案

Hello

If you assume that TextBox1.Text and Label1.Text always contains a number then just multiply the two values and display the result:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Timer1.Enabled = False

    Dim result As String
    result = TextBox1.Text * Label1.Text

    MsgBox(result)
End Sub



If the text values can be something else you may want to convert them to a number first:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Timer1.Enabled = False

    Dim value As Double
    Dim result As String

    If Double.TryParse(TextBox1.Text, value) Then
        'TextBox1.Text is a number
        result = value * Label1.Text
    End If

    MsgBox(result)
End Sub





Valery.


Thanks Valery just the right help I needed. Paul


这篇关于停止在Visual Basic Express中观看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆