Question

In: Computer Science

Write a program to carry out the stated task: When one of the buttons is pressed,...

Write a program to carry out the stated task: When one of the buttons is pressed, the face changes to a smiling face [emoticon :-) ] or a frowning face [emoticon :-(]. Written in Visual Basic.

Solutions

Expert Solution

Below is the form:

Name of important controls:

PictureBox: pbImage

Button: btnChange

Below is the Vb code:

Imports System.IO

Public Class Form1

    Private Sub btnChange_Click(sender As Object, e As EventArgs) Handles btnChange.Click
        'Change the image on button click
        If pbImage.Tag = 0 Then
            pbImage.Image = Image.FromFile("frown.png")
            pbImage.Tag = 1
        ElseIf pbImage.Tag = 1 Then
            pbImage.Image = Image.FromFile("smile.png")
            pbImage.Tag = 0
        End If
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' set Tag to 0 initially
       
pbImage.Tag = 0
    End Sub
End Class

Please note it expects the file name to be 'smile.png' and 'frown.png'. It should be in the folder where the .exe file is. If it is somewhere else, change it in the code accordingly.

Below are the sample outputs:

Upon clicking the "Change" button, it will toggle the image as below:

This completes the requirement. Let me know if you have any questions.

Thanks!


Related Solutions

1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It...
1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It should turn off whenever S1 is released. 2. Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.
Write out the null and alternative hypotheses for the following hypothetical proposal. Carry out a one-sample...
Write out the null and alternative hypotheses for the following hypothetical proposal. Carry out a one-sample Z test to determine significance at the α=0.05 level. PROPOSAL In the field of cancer epidemiology, many researchers are interested in developing risk measurement assays that are intended to influence the screening process for prevention of late stage and metastatic cancers. Parity, or the number of children that a woman has over her lifetime, is associated with the overall risk of breast cancer in...
Write a python program to finish a big-data processing task --- finding out most frequently used...
Write a python program to finish a big-data processing task --- finding out most frequently used words on Wikipedia pages. The execution of the program generates a list of distinct words used in the wikipedia pages and the number of occurrences of each word on these web pages. The words are sorted by the number of occurrences in ascending order. The following is a sample of output generated for 4 Wikipedia pages. 126 that 128 by 133 as 149 or...
(e) Discuss how the systems approach could be used to carry out any task at that...
(e) Discuss how the systems approach could be used to carry out any task at that phase. (f) What role do analytical tools play in the use of the systems approach to carry out that task?           (g) What feedback does the engineer typically provide to engineers at the preceding phases?
Write the equations for carry-out bits for a 4-bit carry lookahead adder. Draw its diagram and...
Write the equations for carry-out bits for a 4-bit carry lookahead adder. Draw its diagram and label all the inputs and the outputs. Compare the delays of the 4-bit ripple-carry and 4-bit carry lookahead adders.
Write a program fragment (not a complete program) which will perform the following task: The int...
Write a program fragment (not a complete program) which will perform the following task: The int variable m currently contains the number of minutes a basketball player played in their last game. Use an IF statement(s) to print out an appropriate message based on the following: If m is from 35 to 48, print the message "very tired" If m is from 10 to 34, print the message "little tired" If m is from 1 to 9, print the message...
Write an array method to carry out each of the following tasks for an array of...
Write an array method to carry out each of the following tasks for an array of integers. Note: you can think of each as a separate problem independent of the others. a) Swap the first and last elements in the array. b) Shi< all elements by one to the right and move the last element into the first posi>on. For example, 1 4 9 16 25 would be transformed into 25 1 4 9 16. c) Replace all even elements...
Write array methods that carry out the following tasks for an array of integers by creating...
Write array methods that carry out the following tasks for an array of integers by creating and completing the “ArrayMethods” class below. Add documentation comments for each method. Provide a test program called ‘Lab5_yourID.java” that test methods of ArrayMethods class. In your test program, use random class to generate array values. public class ArrayMethods { private int[ ] values; //declare instant variables public ArrayMethods (int[ ] initialValues) {values = initialValues;} //constructor public void shiftRight( ) { … } public Boolean...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Task: Write a program that creates a class Apple and a tester to make sure the...
Task: Write a program that creates a class Apple and a tester to make sure the Apple class is crisp and delicious. Instructions: First create a class called Apple  The class Apple DOES NOT HAVE a main method  Some of the attributes of Apple are o Type: A string that describes the apple. It may only be of the following types:  Red Delicious  Golden Delicious  Gala  Granny Smith o Weight: A decimal value representing...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT