|
Im completing a project for my VB class and kind of lost at some things.. these are the requirements:
Julia really liked the How Big is My Room app but realized it would be much
better if she could calculate the cost of ALL of her rooms in the same window. She would keep a
similar layout, but change the program to handle a list of rooms, displaying the size and cost of all
of the rooms and a total cost to resurface the floors in her entire home.
1.
She knows that if she measures the length and width of each room, she can determine the area or
square-footage. (roomSize = roomWidth * roomLength)
2.
To get the price for each room she multiplies the area of the room times the price of the material
(totalCost = roomSize * costOfMaterial)
3.
Presents the user with a picture of carpet or other flooring material (you will need to find an
images on the World Wide Web and download it. Must be in JPG,PNG,GIF,TIF format)
a.
b. Present the user the option to enter her first name
c. Present the user the option to enter her last name
d. Present the user the option to enter the room name
e. Present the user the option to enter the room width (in feet)
f. Present the user the option to enter the room length (in feet)
1) The picture must change to the corresponding floor type
2) The cost of material must change
3) The cost per room for each room must change and be displayed properly
4) The output totals should reflect the change
i. When a user changes a floor type…
Present the user the option to choose a floor type using radio buttons. The text of the radio
button should reflect the type and cost per sq/ft for that type.
g.
Present a list of rooms in a list box. Each room in the list box will be indicated by its room
name
h.
i. Use other listboxes to keep track of the length, width and total cost of a room.
Presents the user the option to submit the entry with a button by clicking with the mouse or
pressing the enter key.
j.Check to make sure all boxes are filled in. Warn the user with a message box that
states "Please enter something in all boxes" (or a similar message) -- (hint: if
textbox1.text <> "" and textbox2.text <> "" then…)
i.
Check to make sure the user has chosen a floor type. Warn the user with a message
that states "Please choose a Floor Type first!" (or a similar message) -- (hint: if
radio1.checked = true then…)
iii. Enter the room information to the appropriate list boxes
a) First Name "Julia"
b) Last Name "Anderson"
1) If the user provides the following input
iv. Output as indicated below…
k. When the user clicks the button…
4. Create a Visual Basic 2012 Program for Julia that does the following
i) "Hello Julia, the Anderson home estimate:"
ii) "Total number of Rooms: 00"
iii) "Total Square Footage: 0.0 sq/ft"
iv) "Total cost to resurface: $0.00"
a) The output should be displayed as follows
i. Wood Floors: $5.00 sq/ft
a. When the form loads, you will need to set the cost of the material and radio buttons text
Programming Assignment #3 - How Big are My Rooms?
i. Wood Floors: $5.00 sq/ft
ii. Carpet: $3.00 sq/ft
iii. "Carpet: $3.00 sq/ft"
iv. "Wood: $5.00 sq/ft"
Other notes:
• The program requires the Option Strict compiler directive
and my code I have so far is :
Option Strict On
Public Class fmResurface
Public Const dblWoodFlooring As Double = 5D
Public Const dblCarpetFlooring As Double = 3D
Dim dbldefaultWoodcost As Double
Dim dbldefaultcarpetcost As Double
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblOutput.Click
End Sub
Private Sub Label1_Click_1(sender As Object, e As EventArgs) Handles lblOutputNumberRooms.Click
End Sub
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GBFloorType.Enter
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
dbldefaultcarpetcost = dblCarpetFlooring
dbldefaultWoodcost = dblWoodFlooring
End Sub
Private Sub Label1_Click_2(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub btnEnter_Click(sender As Object, e As EventArgs) Handles btnEnter.Click
Dim strFirstName As String
Dim strLastName As String
Dim strRoomName As String
Dim strRoomWidth As String
Dim strRoomLength As String
Dim dbltotalcost As Double
strFirstName = txtFirstName.Text
strLastName = txtLastName.Text
strRoomName = txtRoomName.Text
strRoomLength = txtRoomLength.Text
strRoomWidth = txtRoomWidth.Text
If strFirstName <> "" And strLastName <> "" And strRoomLength <> "" And strRoomName <> "" And strRoomWidth <> "" Then
MessageBox.Show("Enter data into boxes!")
End If
dbltotalcost = Val(txtRoomLength.Text) * Val(txtRoomWidth.Text)
If RBWoodFloor.Checked = False And RBCarpet.Checked = False Then MessageBox.Show("Choose a floor type!")
If RBWoodFloor.Checked = True Then dbldefaultWoodcost = dblWoodFlooring
If dbldefaultWoodcost = dblWoodFlooring Then Call lbRoomName.Items.Add(txtRoomName.Text)
If dbldefaultWoodcost = dblWoodFlooring Then Call lbRoomLength.Items.Add(txtRoomLength.Text)
If dbldefaultWoodcost = dblWoodFlooring Then Call lbRoomWidth.Items.Add(txtRoomWidth.Text)
If dbldefaultWoodcost = dblWoodFlooring Then Call lbTotalCost.Items.Add(dbltotalcost * dblWoodFlooring)
ElseIf dbldefaultcarpetcost = dblCarpetFlooring Then Call lbTotalCost.Items.Add(dbltotalcost * dblCarpetFlooring)
If RBCarpet.Checked = True Then dbldefaultcarpetcost = dblCarpetFlooring
If dbldefaultcarpetcost = dblCarpetFlooring Then Call lbRoomName.Items.Add(txtRoomName.Text)
If dbldefaultcarpetcost = dblCarpetFlooring Then Call lbRoomLength.Items.Add(txtRoomLength.Text)
If dbldefaultcarpetcost = dblCarpetFlooring Then Call lbRoomWidth.Items.Add(txtRoomWidth.Text)
End
End Sub
Private Sub lbTotalCost_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lbTotalCost.SelectedIndexChanged
End Sub
Private Sub RBWoodFloor_CheckedChanged(sender As Object, e As EventArgs) Handles RBWoodFloor.CheckedChanged
If RBWoodFloor.Checked Then pccarpet.Image = My.Resources.floor
End Sub
Private Sub RBCarpet_CheckedChanged(sender As Object, e As EventArgs) Handles RBCarpet.CheckedChanged
If RBCarpet.Checked Then pccarpet.Image = My.Resources.nice
End Sub
Private Sub pccarpet_Click(sender As Object, e As EventArgs) Handles pccarpet.Click
End Sub
Private Sub lbRoomName_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lbRoomName.SelectedIndexChanged
End Sub
Private Sub txtFirstName_TextChanged(sender As Object, e As EventArgs) Handles txtFirstName.TextChanged
End Sub
End Class
Tia Lawrence
|
|
|
|
|
Any specific question?
I'd rather not wade through each question simply to check if that's already in the code. Anyone of them in particular you're having trouble with?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes I'm having trouble with moving the data from the text box to the list of seperately, when it calculate and move together, I tried the if else but it keep popping up with a error.
Thanks
|
|
|
|
|
Member 11264383 wrote: moving the data from the text box to the list of seperately, Which list is that? You're already adding data from a textbox to a listbox, so that is probably not what you meant.
Member 11264383 wrote: when it calculate and move together I'd use a button. You could automatically recalculate whenever one of the entries change, but it is really a lot easier to have a button that says "calculate now".
You'd have to foreach each room, and perform the calculation.
Member 11264383 wrote: I tried the if else but it keep popping up with a error. What error?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy is right in the foreach, but for recalculation, I'd have a handler that handles the on change event from each of the boxes, it can all be done in one subroutine
private sub TextboxChanged(sender as object, e as eventargs) handles txtRoomWidth.changed, txtRoomLength.changed, lstFlooringType.changed
dim SquareFootage as single = txtRoomWidth.value * txtRoomLength.value
dim CostPerFoot as single
dim RoomCost as single = Squarefootage * CostPerFoot
dim totalprice as single = 0
foreach RoomPrice as single in RoomPriceList
totalprice += RoomPrice
next
txtTotalprice.value = "Total cost is $" & totalprice
end sub
I'd have used the names you used, but I can't open both windows at once
|
|
|
|
|
This is my first web page automation project, and I don't understand a couple of things.
So I have a form with a WebBrowser Object on it, I load the form, navigate to the web page, the web page loads ...
So the DocumentCompleted event fires?
I noticed it fires for every document requested, so I isolated the page I wanted
The page loads fine first.
Then I fire my automation script, which fixes the errors on the page, fills in the textboxes
I can see the page with my values, for about a millisecond.
[The part I don't' understand]
Then the page loads again, this time with scripts errors for everything, jquery and so forth, and the CSS is blown out.
[Question]
Am I wasting my time with these event handlers,
When I write back to the WebBrowser1.DocumentText, am I forcing the page to load again?
Private Sub frm_download_Data_Load(sender As Object, e As EventArgs) Handles Me.Load
'Suppress the Script Errors
SuppressScriptErrorsOnly(WebBrowser1, False)
'Navigate the the Reseller Login Page
WebBrowser1.Navigate(ddl_URL.Text)
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) _
Handles WebBrowser1.DocumentCompleted
If Not (WebBrowser1.Url.AbsoluteUri = "about:blank") Then
If (e.Url.AbsolutePath = WebBrowser1.Url.AbsolutePath) Then
Select Case WebBrowser1.Url.AbsoluteUri
Case "http://page.asp"
AddHandler CType(sender, WebBrowser).Document.Window.Error, AddressOf Window_Error
http_automation_login.automate(WebBrowser1, g_userName, g_password)
RemoveHandler CType(sender, WebBrowser).Document.Window.Error, AddressOf Window_Error
End Select
End If
End If
End Sub
|
|
|
|
|
The document complete fires after every request.
So how do you tell if the page is fully loaded, so I can fire the submit?
|
|
|
|
|
jkirkerx wrote: When I write back to the WebBrowser1.DocumentText, am I forcing the page to load again?
You haven't shown that part of the code, but it's the most likely cause of the problem you described:
When you set this property, the WebBrowser control automatically navigates to the about:blank URL before loading the specified text. This means that the Navigating, Navigated, and DocumentCompleted events occur when you set this property, and the value of the Url property is no longer meaningful.
If you're reading the DocumentText , changing it, and then writing it back to the WebBrowser , the resulting document won't have the same base URL, so it won't be able to resolve any scripts, stylesheets or images which use relative paths.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That's what happens, the page had to reload when I altered the HTML and wrote it back, causing major chaos there.
So I changed my approach on it, and changed the document using GetElementByID and SetAtrribute
Filled in the textboxes,
Figured out how to submit the page, and off I went into automation.
I've gotten quite far into the website now. Oh and yes this is sanctioned by the website owner, guess they have legacy excel spreadsheets that need data.
|
|
|
|
|
Guys..I wanna do excel data validation with XML.excel sheet contains no.of rows n columns.by using VBA macros..can u suggest me the best way to do it..if any sample code.
|
|
|
|
|
How about some details? What sort of validation? What doe s the data look like?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
hi,
i need to get sql data directory path using vb .net code .
For example
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA
using vb.net
Please help me to find solution
thanks.
|
|
|
|
|
Hi, what exactly do you want? Do you want to get the sql path or want to do some manipulation with it after getting the path?
|
|
|
|
|
Thanks for reply,
I just want to get path of Data folder to create new database using vb code , as per path varies from sql 2005 to sql 2008 so hard coded path wasn't great idea ... so i need to get only data folder path...
I got one sql query which returns exact data folder path that help me to solve my problem...
SELECT SUBSTRING(physical_name, 1,
CHARINDEX(N'master.mdf',
LOWER(physical_name)) - 1) DataFileLocation
FROM master.sys.master_files
WHERE database_id = 1 AND FILE_ID = 1
thanks again...
|
|
|
|
|
Specific files may be in different directories - SQL has default data locations, but the db administrator may choose to put them elsewhere.
for the default location, query the settings:
using (var connection = new SqlConnection("Data Source=.;Integrated Security=SSPI"))
{
var serverConnection = new ServerConnection(connection);
var server = new Server(serverConnection);
var defaultDataPath = string.IsNullOrEmpty(server.Settings.DefaultFile) ? server.MasterDBPath : server.Settings.DefaultFile;
var defaultLogPath = string.IsNullOrEmpty(server.Settings.DefaultLog) ? server.MasterDBLogPath : server.Settings.DefaultLog;
}
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
hi,
i need to get sql data directory path using vb .net code .
For example
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA
using vb.net
Please help me to find solution
thanks.
|
|
|
|
|
Good day friends! Please, I need your help in this stuff<pre>Dim i As Integer
Dim result As Double
For i = -169 To 2400
result = 0.1857*i*120
Next
</pre>
Please, what will be the final answer because I tried manual calculation as follows but not sure is correct. And I got something like this:
result=0.1875*(-169)*120
result=-3802.5
I know that -169 To 2400 will loop from -168-0 AND continue from 0-2399
Please help.
|
|
|
|
|
I see nothing array related.
But, because result is simply recalculated every time, the final answer is:
result = 0.1857 * 2400 * 120. So.. 53481.6
|
|
|
|
|
Thank you. Does that mean that is only the ubound i.e 2400 that you take? And, what would be the answer to this
For i=(0 To 6, 10 To 20)
result= what!
Next
please help because am really confuse in this...
|
|
|
|
|
yes you are correct, the calculation runs as many times specified in your for loop.
BUT as you are not storing the result in a collection of any type the result variable is overwritten each time with the next calculation.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
You can download Visual Studio Express from Microsoft's site and run this code for yourself to see what it does. You'll learn more that way too.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Ok, I head you all. The problem am having is that, I downloaded a sample program and I saw this line of code
<pre>
For c = 0 To 10
For d = 0 To 12
If (c,d) = 1 Then
'action to perform
Else
'action to perforn
End if
Next
Next
</pre>
And, I don't really know how this will be equal to 1. Please, I need to know how this can be calculated so that the outcome will be equal to 1 in order for me to understand the flow of the code.
|
|
|
|
|
Otekpo Emmanuel wrote: If (c,d) = 1 Then
I haven't done VB in a long time but that sure doesn't look like valid VB code.
I think perhaps you meant:
If SomeArray(c,d) = 1 Then
That would just be a 2 dimensional array (like an Excel spreadsheet (Row, Column) which would also explain the 2 loops.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thank you all for your replies. Sorry, if am too inquisitive. In the same program, the below lines of code exists:
Public DistX As Integer
Dim Length As Integer
Public DistToDark(1 To 1850) As Integer
DarkX = DistToDark(Length)
Where the value of Length increments by 1. So, assuming the Length value is 2, what will be the outcome of DarkX?
And, below is another
Dim angle, ray_inc as Double
Public sine(-160 To 2400) As Double
Dim i As Integer
For i = -160 To 2400
angle = ray_inc * i * piDivBy180 'where rays_inc =1.85
sine(i) = sine(angle)
Next
Friends please excercise patience and make me to understand the above logics. Believe me, I have searched google, read many articles but I still found it difficult. My questions are;
what could be the outcome of angle = ray_inc * i * piDivBy180 'where rays_inc =1.85?
What could be the possible outcome of
sine(i) = sine(angle)?
Will each element of array sine be equated to sine(angle)? E.g sine(0) = sine(angle) and so...
|
|
|
|
|
I still say the best thing for you to do is run the code yourself.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|