Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Conversor de Graus

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Conversor de Graus

    Bom galera, resolvi postar aqui na área de VB.Net, alguns prohetos que eu ja fiz no curso de Técnico em Programação. Alguns são (aparentemente) simples, como este conversor de graus;

    Primeiro, você precisará de: 1 GroupBox (grb_graus); 3 Labels; 3 TextBox (txt_fahrenheit, txt_kelvin e txt_celcius); 3 Botões (btn_calcular, btn_limpar e btn_sair); O design do form fica à seu criterio. Vamos ao código!

    Dentro do "btn_calcular" (Botão Calcular) coloque isso:

    If IsNumeric(txt_celsius.Text) Then

    txt_fahrenheit.Text = txt_celsius.Text * 1.8 + 32
    txt_kelvin.Text = txt_celsius.Text + 273.15

    ElseIf IsNumeric(txt_fahrenheit.Text) Then
    txt_celsius.Text = (txt_fahrenheit.Text - 32) / 1.8
    txt_kelvin.Text = (txt_fahrenheit.Text + 459.67) / 1.8

    ElseIf IsNumeric(txt_kelvin.Text) And Val(txt_kelvin.Text >= 0) Then
    txt_fahrenheit.Text = txt_kelvin.Text * 1.8 - 459.67
    txt_celsius.Text = txt_kelvin.Text - 273.15

    End If
    Dentro do "btn_sair" (Botão Sair) coloque isso:

    End
    Fácil né?

    No "btn_limpar" (Botão Limpar) coloque isso:

    txt_celsius.Text = " "
    txt_fahrenheit.Text = " "
    txt_kelvin.Text = " "
    Agora, vamos usar uma função chamada e.keychar, que serve para impedir que o usuario digite letras ao invés de números no TextBox. Clique e selecione a TextBox, vá em propriedades e selecione a função Events lá em cima. Procure pelo evento KeyPress, clique 2 vezes sobre ele e coloque este código dentro:

    If Not Char.IsNumber(e.KeyChar) Then

    e.Handled = True

    End If
    OBS: Faça isso com as 3 TextBox.

    Bom, é isso. Espero que gostem, logo voltarei com mais projetos

  • Font Size
    #2
    Projetos

    desculpem o erro --'

    Comment

    X
    Working...
    X