Jump to content
Pt Freelancer

[VB.NET] Mesagens de Erro

Recommended Posts

Pt Freelancer

O projecto ta a ser feito em vb 2005 express edition e é uma simples maquina de calcular

Public Class Units
    Const MB_YESNO = 4
    Const IDYES = 6
    Const MB_ICONQUESTION = 32
    Const IDNO = 7
    Const IDOKONLY = 1
    Const MB_OKONLY = 0
    Const MB_EXCLATION = 48
    Dim Message As String
    Dim Answer As Integer
    Dim Buttons As Integer
    Dim Title As String

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Message = "Do you want to quit?"
        Buttons = MB_YESNO + MB_ICONQUESTION
        Title = "IC Calculator"
        Answer = MsgBox(Message, Buttons, Title)

        If Answer = IDYES Then
            End
        Else
            e.Cancel = True
        End If

    End Sub



    Private Sub execute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexecute.Click

        'Type of Data

        Dim Cons As Integer
        Dim Bomber As Integer
        Dim Fighter As Integer
        Dim Soldier As Integer
        Dim Tran As Integer
        Dim Agent As Integer
        Dim Wizard As Integer
        Dim Droid As Integer

        ' Declared as

        Cons = Val(txtCons.Text)
        Bomber = Val(txtBombers.Text)
        Fighter = Val(txtFighters.Text)
        Soldier = Val(txtSoldiers.Text)
        Tran = Val(txtTransports.Text)
        Agent = Val(txtAgents.Text)
        Wizard = Val(txtWizards.Text)
        Droid = Val(txtDroids.Text)

        If Cons > 100 And Cons > 0 Then

            Message = "Construction bonus must be between 100 and 0"
            Buttons = IDOKONLY + MB_EXCLATION
            Title = "IC Calculator"
            Answer = MsgBox(Message, Buttons, Title)

        Else

            'Calculation

            'Gold
            txtGold.Text = Format$(((400 / (1 + (Cons / 100))) * Bomber) _
            + ((200 / (1 + (Cons / 100))) * Fighter) _
            + ((100 / (1 + (Cons / 100))) * Soldier) _
            + ((800 / (1 + (Cons / 100))) * Tran) _
            + ((150 / (1 + (Cons / 100))) * Agent) _
            + ((150 / (1 + (Cons / 100))) * Wizard) _
            + ((50 / (1 + (Cons / 100))) * Droid), "############")
        
        End If 

o q eu queria fazer agora, era q desse tambem erro quando o utilizador escrevesse caracteres sem serem numeros nos campos como txtcons.Text e txtbombers.Text, e possivel?

Edit: tive um problema e fiz um double post (so agora e q percebi q n se pode fazer tabs..) apaguei o outro, espero n ter causado nenhum problema

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • 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.