Jump to content

Mobile Calculator > URGENT!

DouglinhasZN

it is an assignment indeed, and i just joined the course, its been 4 months, i have 2 leessons of programming a week, and our teach is not the greatest. 

so yeah it is a bit hard for me

Link to comment
Share on other sites

Link to post
Share on other sites

Im not the best at programming we do different lessons and in those lessons im excellent.. its just the programming im slacking, so dont be too quick to judge 

Link to comment
Share on other sites

Link to post
Share on other sites

Im not the best at programming we do different lessons and in those lessons im excellent.. its just the programming im slacking, so dont be too quick to judge 

 

There's a large difference between 'not being the best at' and not bothering at all. From the content of this thread it seems (at least to me) to be leaning heavily over towards the latter of those two. If one were 'not the best at' then they would possess at least some understanding/ability in the subject would they not?

 

Have you approached your teacher with your issues?

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

IMO having bad prof/teacher is no excuse for not learning anything. There are millions of websites that contain tutorials and documentation on what ever programming language you will ever need/want to learn, there are also a lot of books out there. If you're simply not understanding course material or any other programming tutorials it is time to find a new path of education since programming will rip you to pieces.

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

I did do the coding though. I do possess some understanding, its just not as good as your senpai

Link to comment
Share on other sites

Link to post
Share on other sites



Public Class SwampPhones

Dim NS As Single

Private Customer_Name As String

Private House_number As String

Private Post_code As String

Private Mobile_number As String

Private costs_of_phone_calls_made As Decimal

Private cost_of_text_sent As Decimal

Private cost_of_internet_usage As Decimal

Private total_monthly_bill As Decimal

Private numbers_of_minutes_used As Single

Private number_of_texts_sent As Single

Private mbs_of_internet As Single

Private Sub btn1_Click(sender As Object, e As EventArgs) Handles btncalculate.Click

Dim diff As Decimal

Dim temp_cost_of_phone_calls_made As Decimal

Customer_Name = txtcust.Text

House_number = txthouse.Text

Post_code = txtpost.Text

Mobile_number = txtmobile.Text

txtcost1.Text = costs_of_phone_calls_made

txtcost2.Text = cost_of_text_sent

txtcost3.Text = cost_of_internet_usage

txtcost4.Text = total_monthly_bill

If Not Decimal.TryParse(txtcost1.Text, costs_of_phone_calls_made) Then

MessageBox.Show("Invalid input", "Error")

Exit Sub

End If

If rbt1.Enabled = True Then

End If

' If costs_of_phone_calls_made <= 500 And cost_of_text_sent <= 500 And cost_of_internet_usage <= 500 Then

'End If

total_monthly_bill = NS + temp_cost_of_phone_calls_made

total_monthly_bill = total_monthly_bill * 1.2

txtcost4.Text = total_monthly_bill

txtminutesused.Text = temp_cost_of_phone_calls_made

If temp_cost_of_phone_calls_made > 500 Then

temp_cost_of_phone_calls_made = 0

Else

temp_cost_of_phone_calls_made = -500

temp_cost_of_phone_calls_made = temp_cost_of_phone_calls_made * 0.2

End If

txtcost1.Text = temp_cost_of_phone_calls_made

If costs_of_phone_calls_made = 500 Then

diff = costs_of_phone_calls_made - 500

Dim isEqual As Boolean = (diff = 0.2)

temp_cost_of_phone_calls_made = isEqual

' msgbox(temp_costs_phone_calls_made)

End If

End Sub

Private Sub rbt1_CheckedChanged(sender As Object, e As EventArgs) Handles rbt1.CheckedChanged

NS = 20

End Sub

Private Sub rbt2_CheckedChanged(sender As Object, e As EventArgs) Handles rbt2.CheckedChanged

NS = 25

End Sub

End Class

Ive done the minor changes.. on the cost of phone calls made field when i press to calculate I get -10. I dont know where this is coming from and also everytime I write something on the field numbers of minutes used then click calculate that number resets.

Edited by DouglinhasZN
Link to comment
Share on other sites

Link to post
Share on other sites

@DouglinhasZN you're adding in the code I wrote without understanding it and you're using it wrong. So I wont be writing you any more code. Here's a few things wrong with your current code.

 


 

You're doing this again

txtcost1.Text = costs_of_phone_calls_madetxtcost2.Text = cost_of_text_senttxtcost3.Text = cost_of_internet_usagetxtcost4.Text = total_monthly_bill

So let me repeat myself. You're filling the text boxes with default values (ie: zero) because none of those variables have been assigned anything before they are being used. A common thing you're doing in your code as you'll see.

 

Then you do this

If Not Decimal.TryParse(txtcost1.Text, costs_of_phone_calls_made) Then    MessageBox.Show("Invalid input", "Error")    Exit SubEnd If

Which takes the zero you just put in the text box and puts it back into costs_of_phone_calls_made. Basically it's not doing anything useful.

 


 

This was not code for you to use.

Dim isEqual As Boolean = (diff = 0.2)temp_cost_of_phone_calls_made = isEqual

It was written to explain why what you had previously was wrong. It's still wrong. A Boolean type will contain True or False. You're assigning a Boolean type to a Decimal type which isn't right.

 


 

Nothing has been assigned to temp_cost_of_phone_calls_made so it's also just it's default value of zero.

total_monthly_bill = NS + temp_cost_of_phone_calls_made

Also, you're using NS before making sure it's assigned anything. What if the button code runs before someone selected 3G or 4G? Then NS would contain zero because it would just be its default value. It's always important to validate your input and handle things when something is wrong.

 


 

temp_cost_of_phone_calls_made still hasn't been assigned anything and you're using it here again

txtminutesused.Text = temp_cost_of_phone_calls_madeIf temp_cost_of_phone_calls_made > 500 Then    // ...Else    // ...End If

It's always zero so it'll never be > 500 and will always enter the Else block.

Link to comment
Share on other sites

Link to post
Share on other sites

@DouglinhasZN you're adding in the code I wrote without understanding it and you're using it wrong. So I wont be writing you any more code. Here's a few things wrong with your current code.

 


 

You're doing this again

txtcost1.Text = costs_of_phone_calls_madetxtcost2.Text = cost_of_text_senttxtcost3.Text = cost_of_internet_usagetxtcost4.Text = total_monthly_bill

So let me repeat myself. You're filling the text boxes with default values (ie: zero) because none of those variables have been assigned anything before they are being used. A common thing you're doing in your code as you'll see.

 

Then you do this

If Not Decimal.TryParse(txtcost1.Text, costs_of_phone_calls_made) Then    MessageBox.Show("Invalid input", "Error")    Exit SubEnd If

Which takes the zero you just put in the text box and puts it back into costs_of_phone_calls_made. Basically it's not doing anything useful.

 


 

This was not code for you to use.

Dim isEqual As Boolean = (diff = 0.2)temp_cost_of_phone_calls_made = isEqual

It was written to explain why what you had previously was wrong. It's still wrong. A Boolean type will contain True or False. You're assigning a Boolean type to a Decimal type which isn't right.

 


 

Nothing has been assigned to temp_cost_of_phone_calls_made so it's also just it's default value of zero.

total_monthly_bill = NS + temp_cost_of_phone_calls_made

Also, you're using NS before making sure it's assigned anything. What if the button code runs before someone selected 3G or 4G? Then NS would contain zero because it would just be its default value. It's always important to validate your input and handle things when something is wrong.

 


 

temp_cost_of_phone_calls_made still hasn't been assigned anything and you're using it here again

txtminutesused.Text = temp_cost_of_phone_calls_madeIf temp_cost_of_phone_calls_made > 500 Then    // ...Else    // ...End If

It's always zero so it'll never be > 500 and will always enter the Else block.

im sorry if i copied ur code, i was trying to get ride of the problem, and somehow I manage to fix it with coding so I though it would be fine to leave it there

Link to comment
Share on other sites

Link to post
Share on other sites

im sorry if i copied ur code, i was trying to get ride of the problem, and somehow I manage to fix it with coding so I though it would be fine to leave it there

It's not a big deal to use the code I wrote to help you out. That is why I did it. However you should generally understand someone's code before using it. If you don't, you can use it wrong. You can also run into the problem of not being able to explain something to your teacher if they accuse you of cheating or something.

Link to comment
Share on other sites

Link to post
Share on other sites

correct, well I thank you so much for your help, but ive decided to be happy with an merit and leave the distinction behind, as its being such a pain in the ass :).. I greatly appreciate your help my friend, the only one who acc helped.

Ive tried today multiple times I just dont know the next step to calculate the input of the user, and I dont see my self learning it till friday as there is still errors to be fixed.

Link to comment
Share on other sites

Link to post
Share on other sites

[code]Public Class Form1    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click        Dim Mins, Tex, MB As String ' declares mins, trextrs and mb as vaaiubvles with data type string        Mins = TextBox1.Text ' inputs datra frrom textgvox into varaible        Tex = TextBox1.Text ' up        MB = TextBox3.Text ' up        If TextBox1.Text = "" Then  '            Mins = "0"              ' sets the varaibel to 0        End If        If TextBox2.Text = "" Then '            Tex = 0 '        End If '         If TextBox3.Text = "" Then '            MB = 0 '        End If '        If Mins < 500 Then            Mins = 0        Else            Mins -= 500            Mins *= 0.2        End If        If Tex < 500 Then            Tex = 0        Else            Tex -= 500            Tex *= 0.1        End If        If MB < 500 Then            MB = 0        Else            MB -= 500            MB *= 0.5        End If        Dim total As Single        total = Convert.ToSingle(Mins) + Convert.ToSingle(Tex) + Convert.ToSingle(MB) + 20 * 1.2        TextBox4.Text = total    End Sub    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click        Dim Mins, Tex, MB As String        Mins = TextBox1.Text        Tex = TextBox1.Text        MB = TextBox3.Text        If TextBox1.Text = "" Then            Mins = "0"        End If        If TextBox2.Text = "" Then            Tex = 0        End If        If TextBox3.Text = "" Then            MB = 0        End If        If Mins < 500 Then            Mins = 0        Else            Mins -= 500            Mins *= 0.2        End If        If Tex < 500 Then            Tex = 0        Else            Tex -= 500            Tex *= 0.1        End If        If MB < 500 Then            MB = 0        Else            MB -= 500            MB *= 0.5        End If        Dim total As Single        total = Convert.ToSingle(Mins) + Convert.ToSingle(Tex) + Convert.ToSingle(MB) + 25 * 1.2        TextBox4.Text = total    End SubEnd Class[/code]

i've re done my code and it did work the first time then after a while it start giving me errors.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×