Any way to add a counter?, to count the elements/ # of prime factors outputted to TextBox2.Text. VB
Below is the solution:
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
'declare variable
Dim count As Integer =
0
Dim N, x As
Integer
N =
Val(TextBox1.Text)
For x = 2 To N - 1 'loop
n-1 times
If N Mod x = 0 Then
count += primeNumber(x) 'check for the number is prime or not
End If
Next
'display to the
textbox
TextBox2.Text =
count
End Sub
Private Function primeNumber(x As Integer) As
Integer 'function that will check for the prime
Dim j As Integer
Dim t As Boolean
t = True
For j = 2 To (x -
1)
If x Mod j = 0 Then 'check for the prime
t = False
Exit For
End If
Next j
If t Then 'if number is
prime return 1 to count 1
Return 1
Else
Return 0 'if number is not prime return 0 to count 0
End If
End Function
sample output:
Any way to add a counter?, to count the elements/ # of prime factors outputted to...
I am new to programming (2 weeks of playing with it) I have written code for a timer in Visual Studio 2013. I am wondering if someone can show me how to write code/what the code would look like in a MODULE1.vb. I was thinking that for this timer I could create MsgBox using a DO UNTIL LOOP that would pop up every 20 seconds that says "hurry up!" until 1 minute has passed. As I said I am just...
Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game simulates a card game where the cards a placed face down and the player flips over pairs of cards in an attempt to find matching cards. Program Procedure Display a 4x4 grid of “face down” cards. Assign the letters A through H randomly to the cards in pairs. Allow the user to click on a card to “flip” it over and...
I’m attempting to create the functioning GUI (bottom photo)
from the coding in the first photo. I’m unclear as to what I’m
missing to complete the code. Thank you
a Homework 8 similar to Exercise 16 8.pdf (page 1 of 2) Public Class Formi Dim answer As Integer Sub Random() Dim random As New Random() answer randon.Next (1, 1ee) End Sub Private Sub Formi Load(ByVal sender As System.Object, Byval e As System. EventArgs) Handles MyBase. Load Random() End Sub Private...
WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING, HOW MANY QUESTIONS THEY GOT RIGHT AND WRONG. Public Class Form1 Dim r As Random = New Random Dim no1, no2 As Integer Private Sub rdbAdd_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAdd.CheckedChanged txtAnswer.Clear() txtAnswer.BackColor = Color.White no1 = randomInt() no2 = randomInt() lblOperation.Text = "+" txtNumber1.Text = no1.ToString() txtNumber2.Text = no2.ToString() End Sub Public Function randomInt() As Integer Return r.Next(20, 120) End Function...
so im trying to make a grade program and idk what im doing wrong actually if someone can help? (heres the lines of code i have so far if its wrong let me know how to fix them Option Strict On Option Explicit On Public Class Form1 Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim lblscore1 As Double Dim lblscore2 As Double Dim lblscore3 As Double lblscore1 = CDbl(Txtscore1.Text) lblscore2 = CDbl(Txtscore2.Text) lblscore3 = CDbl(Txtscore3.Text) lblaverage =...
I need help with this problem in Visual Basic 2012: Write a program that allows the user to specify two numbers and then adds, subtracts, multiplies, or divides them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. Whenever one of the numbers in an input text box is changed, the output text box should be cleared. Also, if the number 0 is entered into the second text box,...
Public Class Form1 Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click Dim room As Double 'Assigns room as double Dim rate As Double 'Assigns rate as double Dim room2 As Double 'Assigns room as double Dim overallRate As Double 'Assigns overall as double Dim a As Integer 'Assign a as an integer For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors With...
I am trying to build a program in Visual Basic that allows user
to enter an objects mass and velocity and to display the Kinetic
energy. The application should have a function KineticEnergy that
accepts a moving objects mass and velocity as arguments. The
function should return the objects KE.
i get these three errors when trying to run the program I need
help how would I fix this so it runs successfully? Thanks in
advance!
Start 16 ml.vb* +...
C# Windows Form Application (CALCULATOR): (This is the instruction below): Windows Calculator that will going to create a Windows Form Application that will mimics a calculator. This is the screenshot how it shouldl look like. Calculator It should have a textbox and the following buttons: + Addition - Subtraction * Multiplication / Division = Equals (Will perform the final calculation) C Clear (Will clear the text box) There will be no maximize or minimize buttons. The rules are these: 2...
Visual Basic: Create an application that simulates a tic tac toe game. The form uses 9 large labels to display the x's and o's. The application should use a two dimensional integer array to simulate the game board in memory. When the user clicks the "New Game" button the application should step throguh the array storing a random number of 0 to 1 in each element. The numer 0 represent the letter o and the number 1 reprsents the letter...