Jump to content

Recommended Posts

Posted

Srs . alguém para me ajudar  ??

Tenho que converter  uma escala de  0 - 32000   em   -5 a  + 5    num programinha que estou criando ...

onde          0  =  -5

          32000  =  +5

Posted

Boa tarde

Partindo de que é digitado um valor e numa caixa de texto (text1) e o valor convertido será colocado numa outra caixa de texto (text2). a conversão é feita clicando num botão (command1).

Private Sub Command1_Click()
	Dim valorEntrada As Integer
	Dim valorSaida As Double

	'1º tranformar em 0 a 1
	valorEntrada = Val(Text1.Text)
	valorSaida = valorEntrada / 32000

	'2º transformar 0 a 10
	valorSaida = valorSaida * 10

	'3º transformar de -5 a 5
	valorSaida = valorSaida - 5
	Text2.Text = valorSaida

End Sub

pode ser feito de uma só vez

Private Sub Command1_Click()
    Dim valorEntrada As Integer
    Dim valorSaida As Double

    'de uma só vez
    valorEntrada = Val(Text1.Text)
    valorSaida = (valorEntrada / 32000 * 10) - 5

    Text2.Text = valorSaida

End Sub

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.