Click here to Skip to main content
15,886,919 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: email Pin
Dave Kreskowiak1-Dec-04 3:30
mveDave Kreskowiak1-Dec-04 3:30 
GeneralRe: email Pin
Mekong River2-Dec-04 10:39
Mekong River2-Dec-04 10:39 
GeneralPackage and Deployment Pin
nitin_ion1-Dec-04 0:27
nitin_ion1-Dec-04 0:27 
GeneralRe: Package and Deployment Pin
Dave Kreskowiak1-Dec-04 3:26
mveDave Kreskowiak1-Dec-04 3:26 
GeneralAbout GUID Pin
iamalik30-Nov-04 19:28
professionaliamalik30-Nov-04 19:28 
GeneralRe: About GUID Pin
Tom John30-Nov-04 22:46
Tom John30-Nov-04 22:46 
GeneralAnother Problem Pin
Tech 4 a dummy30-Nov-04 18:03
Tech 4 a dummy30-Nov-04 18:03 
GeneralRe: Another Problem Pin
Tom John30-Nov-04 22:28
Tom John30-Nov-04 22:28 
Put 2 textboxes, 3 labels and a button on a form:

Label1:
Text = "Miles driven:"
Location = 32, 24

Label2:
Text = "Gallons used:"
Location = 32, 48

Label3:
Text = ""
Location = 144, 80

TextBox1:
Text = ""
Location = 144, 24

TextBox2:
Text = ""
Location = 144, 48

Button1:
Text = "Calculate"
Location = 232, 112


Add the following code

<br />
Private Function MilesPerGallon(ByVal miles As Integer, ByVal gallons As Integer) As Double<br />
<br />
        Return miles / gallons<br />
<br />
End Function<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
        If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then<br />
            Label3.Text = GetMPG(CInt(TextBox1.Text), CInt(TextBox2.Text)).ToString & " mpg"<br />
        End If<br />
<br />
End Sub<br />


Then you may also want to ensure the user can only enter numbers into the textboxes:

<br />
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress, TextBox2.KeyPress<br />
<br />
        If Not IsNumeric(e.KeyChar) Then e.Handled = True<br />
<br />
End Sub<br />


Hope this helps

Tom
GeneralRe: Another Problem Pin
Dave Kreskowiak1-Dec-04 1:05
mveDave Kreskowiak1-Dec-04 1:05 
GeneralRe: Another Problem Pin
Tom John1-Dec-04 1:18
Tom John1-Dec-04 1:18 
GeneralRe: Another Problem Pin
Colin Angus Mackay1-Dec-04 3:09
Colin Angus Mackay1-Dec-04 3:09 
Questionwhat's wrong with this code ? Pin
bahruddina30-Nov-04 16:47
bahruddina30-Nov-04 16:47 
AnswerRe: what's wrong with this code ? Pin
Tom John30-Nov-04 22:39
Tom John30-Nov-04 22:39 
GeneralRe: what's wrong with this code ? Pin
bahruddina1-Dec-04 14:00
bahruddina1-Dec-04 14:00 
GeneralI Need Help Please!!!!!!! Pin
Tech 4 a dummy30-Nov-04 16:45
Tech 4 a dummy30-Nov-04 16:45 
GeneralRe: I Need Help Please!!!!!!! Pin
Anonymous30-Nov-04 19:12
Anonymous30-Nov-04 19:12 
GeneralRe: I Need Help Please!!!!!!! Pin
Colin Angus Mackay1-Dec-04 0:19
Colin Angus Mackay1-Dec-04 0:19 
GeneralRe: I Need Help Please!!!!!!! Pin
Tom John1-Dec-04 5:57
Tom John1-Dec-04 5:57 
GeneralRe: I Need Help Please!!!!!!! Pin
Dave Kreskowiak1-Dec-04 0:59
mveDave Kreskowiak1-Dec-04 0:59 
GeneralRFID.. Pin
Member 155626930-Nov-04 14:19
Member 155626930-Nov-04 14:19 
GeneralRe: RFID.. Pin
Colin Angus Mackay1-Dec-04 0:20
Colin Angus Mackay1-Dec-04 0:20 
GeneralRe: RFID.. Pin
Dave Kreskowiak1-Dec-04 0:57
mveDave Kreskowiak1-Dec-04 0:57 
Generalplease help me pass. Pin
jettavr66630-Nov-04 7:53
jettavr66630-Nov-04 7:53 
GeneralRe: please help me pass. Pin
Dave Kreskowiak30-Nov-04 9:48
mveDave Kreskowiak30-Nov-04 9:48 
GeneralRe: please help me pass. Pin
R. Thomas30-Nov-04 14:41
R. Thomas30-Nov-04 14:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.