|
Won't Compile
|
| Dudeman |
Posted on 07/16/2014 13:41:00
|

Super Admin

Posts: 1277
Joined: 03.01.12
|
Anyone know Visual Basic? I have a feeling it's the Console.WriteLine w/company name&cost but not sure
Code
Module Module1
Sub Main()
'local variables
Const fiberCost As Double = 0.87
Dim companyName As String
Dim numFeet As Double = 0
Dim totalCost As Double = 0
Console.Write("Enter company name: ")
companyName = Console.ReadLine()
Console.Write("Enter number of Fiber: ")
numFeet = Console.ReadLine()
totalCost = numFeet * fiberCost
Console.WriteLine("Your company " + companyName + "had a total cost of $ " + totalCost +)
'this causes apause so you can see your program
Console.Write("Press enter to continue...")
Console.ReadLine()
End Sub
Edited by Dudeman on 07/16/2014 16:57:49
 |
| |
|
|
| ninja |
Posted on 07/16/2014 15:35:49
|

Super Admin

Posts: 4174
Joined: 15.11.10
|
Use code tags when posting code!
I don't know VB but I would guess that Console.ReadLine() returns a string so it doesn't like you trying to store it as a double and do arithmetic with it.
For the console writing line, check whether you can concatenation strings with doubles, and you probably want to remove that last plus.
Edited by ninja on 07/16/2014 15:37:45


My brain is open.
- Paul Erdős |
| |
|
|
| Mist |
Posted on 07/16/2014 16:19:29
|

Numpty

Posts: 1242
Joined: 22.07.13
|
Is it me or does anyone else not understand this language? |
| |
|
|
| Dudeman |
Posted on 07/16/2014 16:58:33
|

Super Admin

Posts: 1277
Joined: 03.01.12
|
ninja wrote:
Use code tags when posting code!
I don't know VB but I would guess that Console.ReadLine() returns a string so it doesn't like you trying to store it as a double and do arithmetic with it.
For the console writing line, check whether you can concatenation strings with doubles, and you probably want to remove that last plus.
Edited for your viewing pleasure XD and I'll take a look at that ReadLine()
 |
| |
|
|
| RazNinjaMike |
Posted on 07/17/2014 06:48:58
|

Moderator

Posts: 4586
Joined: 20.11.10
|
i believe dudeman is trying to get the boobs on his desktop background to move |
| |
|
|
| Dudeman |
Posted on 07/17/2014 09:01:27
|

Super Admin

Posts: 1277
Joined: 03.01.12
|
RazNinjaMike wrote:
i believe dudeman is trying to get the boobs on his desktop background to move
It's finding a companies cost to put in Fiber Optic Cable between two buildings :/
 |
| |
|
|
| ninja |
Posted on 07/17/2014 10:38:11
|

Super Admin

Posts: 4174
Joined: 15.11.10
|
Did you manage to debug it?


My brain is open.
- Paul Erdős |
| |
|
|
| Dudeman |
Posted on 07/17/2014 14:50:26
|

Super Admin

Posts: 1277
Joined: 03.01.12
|
easy and yes.....it was the addition signs, they were supposed to be ampersands (&)
I think pseudocode has the addition signs to seperate calling for variables and actually quoting them.
TLDR; I just mixed up VB with Pseudocode rookie mistake :/
P.S. After this class I'd love to shoot the shit with some of you other programmers. I think it's fairly easy moving from language to language as long as you are alright at Pseudocode. Or so I hear. Hell, we can always use more programmers in the clan. amiright?
Edited by Dudeman on 07/17/2014 14:53:03
 |
| |
|
|
| ninja |
Posted on 07/17/2014 17:33:48
|

Super Admin

Posts: 4174
Joined: 15.11.10
|
Dudeman wrote:
easy and yes.....it was the addition signs, they were supposed to be ampersands (&
I think pseudocode has the addition signs to seperate calling for variables and actually quoting them.
TLDR; I just mixed up VB with Pseudocode rookie mistake :/
P.S. After this class I'd love to shoot the shit with some of you other programmers. I think it's fairly easy moving from language to language as long as you are alright at Pseudocode. Or so I hear. Hell, we can always use more programmers in the clan. amiright?
Many languages overload + for string concatenation, so that's probably why you've seen that and used it.
This Stackoverflow post explains the problem you had: http://stackoverf...-in-vb-net
In essence, the compiler tried to cast your string to a double and add it to the double (since + is a numerical operator). However, you wanted to concatenate the string with the double, so you're best off using the & which is reserved for string concatenation.


My brain is open.
- Paul Erdős |
| |
|
|
| Smurf |
Posted on 07/25/2014 12:05:27
|

Wanker

Posts: 552
Joined: 11.06.12
|
It looks like your doing good so far. From what the code looks like, you have a bit of C+ and VB mixed in it. Haven't seen much of this because C+ and C++ is so much more in depth than actual VB. This is my code for writing/reading lines in VB.
Here is the code to write to the file:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
FileIOPermissionAccess()
If TextBox1.Text = "[ZÅ]" Then
MsgBox("Enter a Player's name to add them.", MsgBoxStyle.Exclamation, "Error"
Else
File.AppendAllText(c, TextBox1.Text & vbCrLf)
TextBox1.Text = "[ZÅ]"
MsgBox("Player Added to the list", MsgBoxStyle.Information, "Saved!"
ReadFile()
End If
Here is the code to read the file (Readfile())
Private Sub ReadFile()
Try
ComboBox1.Items.Clear()
a = File.OpenText(c)
While a.Peek <> -1
b = a.ReadLine()
ComboBox1.Items.Add(
End While
a.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
The Readfile() I have to create on my own so I could make a call to the code. The Readfile() will call the sub in the button1_click then also close the file so it doesn't stay open in RAM
If you need any help dudeman, you can message me over the site or catch me on Xfire when I am on. I have two semesters of VB and have all the programs from the first semester. Unfortunately I wasn't able to recover second semesters code off my failing HDD
Edited by Smurf on 07/25/2014 12:07:58

 |
| |
|
|
| Dudeman |
Posted on 07/26/2014 04:42:55
|

Super Admin

Posts: 1277
Joined: 03.01.12
|
Smurf wrote:
It looks like your doing good so far. From what the code looks like, you have a bit of C+ and VB mixed in it. Haven't seen much of this because C+ and C++ is so much more in depth than actual VB. This is my code for writing/reading lines in VB.
Here is the code to write to the file:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
FileIOPermissionAccess()
If TextBox1.Text = "[ZÅ]" Then
MsgBox("Enter a Player's name to add them.", MsgBoxStyle.Exclamation, "Error"
Else
File.AppendAllText(c, TextBox1.Text & vbCrLf)
TextBox1.Text = "[ZÅ]"
MsgBox("Player Added to the list", MsgBoxStyle.Information, "Saved!"
ReadFile()
End If
Here is the code to read the file (Readfile())
Private Sub ReadFile()
Try
ComboBox1.Items.Clear()
a = File.OpenText(c)
While a.Peek <> -1
b = a.ReadLine()
ComboBox1.Items.Add(
End While
a.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
The Readfile() I have to create on my own so I could make a call to the code. The Readfile() will call the sub in the button1_click then also close the file so it doesn't stay open in RAM
If you need any help dudeman, you can message me over the site or catch me on Xfire when I am on. I have two semesters of VB and have all the programs from the first semester. Unfortunately I wasn't able to recover second semesters code off my failing HDD
Sounds good, bud I may have to take you up on that. I received a 88 on my midterm this week but the assignments are sometimes difficult.
 |
| |
|
|
| Smurf |
Posted on 08/07/2014 17:31:43
|

Wanker

Posts: 552
Joined: 11.06.12
|
Dudeman
Sounds good, bud I may have to take you up on that. I received a 88 on my midterm this week Grin but the assignments are sometimes difficult.
Hey no problem. I passed my VB class with flying colors. This shit is my life now. I can't stop typing code 
If im not on xfire. Message me over the site and I should get an email from it. If not, just email me at my address and I will definitely get it - Spidyshood@yahoo.com
Edited by Smurf on 08/07/2014 17:46:07

 |
| |
|