-
[RESOLVED] [2008] Please help me Build a Visual Basic Program from this Excel file
Hello there this is my first post in this forum and i hope to get enough help. I am a mechanical engineer and i have a term project which should be done in VB and submitted in a month. This is a picture of my excel file.
http://aycu35.webshots.com/image/475...8995777_rs.jpg
Now instead of Excel i want to build a software using VBA with 5 input parameters. After the 5th input parameter is entered i get the
drawing and the
common features
gear features
pinion features
Could someone help me with this please ?
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Hi and welcome to the forum.
Just to let you know, that generally we don't write code for you.
Have a go at it first, provide your code and problem and we will try to help, or point you in the right direction.
Hope this helps.
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
I dont even have VB installed wonder where can i get that at first :S
Anyways heres my excel file:
http://www.zshare.net/download/85156640d56348
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
As SonicBoomAu has said, give it a go first, and then ask us for help. Even if it is a complete shambles ( believe me, I have done that before! ) then these guys and gals will help you.
Free VB.Net 2008 site
http://www.microsoft.com/express/vb/Default.aspx
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
So what is the minimum effort that i should do to get enuf help ? Build a user interface ?
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Have you any programing experience?
If not then who ever set you the tast to do this within a month was very cruel.
We can not generally help you with the User interface, that is down to you, we can however help you with Code.
Downloand and install VB.
BUild a user interface how you want it, then attempt to create code, when you come to a point where you realise you cant do what you want, come and chat again, representing the code you have already tried before.
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Thanx for clarifying things man. Basically im a mechanical Engineer , i recall taking a course when i first entered the university a 3 credit hour course. Simple Visual Basic Programming. If/Then statemen , For Next , Nested if. I also remember making simple programs back in year 2002. 1 program was to show hidden passwords **** by putting the mouse over the **** shows you the letters or numbers inserted. Another one was Drag/Drop to move pictures into boxes and get a msg " Correct " , Incorrect. Anyways This Excel file took like 3 months to do some research and read machine design books. Basically its to produce Spur gears. a pinion is a gear but smaller in diameter.
Anyways the purpose of this excel file is to get a mathematical relation with the CNC machine. CNC stands for Computer Numerical Control machine. To break things down imagine a printer. A printer gives us paper wheras a CNC machine gives us objects. This column is the most important and considered as an input to the CNC machine.
http://aycu18.webshots.com/image/444...6034089_rs.jpg
After that code is uploaded to the CNC machine. this is the output.
http://aycu32.webshots.com/image/473...7935994_rs.jpg
http://aycu09.webshots.com/image/480...4037482_rs.jpg
so generally speaking i want to build a user interface with 5 input parameters. to meet the user requirments. Then hitting "Next" button. All calculations are done internally " Hidden". with an option to save the generated CNC code.File >> Save As >> and then extract the cnc code to a txt file.
BTW im not sure how to start with Sequence Input Box.
For instance i want 5 inuput boxes to come up.
and after the 5th input box , in my case Diametral Pitch Pd.
the drawing is shown with the common feateres etc and an option to save the CNC code.
Is there a code to do a sequence input Box ? and how can i make all the code to be hidden and not shown to the user?
I took some ideas from built EXE spur gear programs.
Im not sure how much time does something like this will take :
http://aycu12.webshots.com/image/403...9651635_rs.jpg
http://aycu38.webshots.com/image/428...1090769_rs.jpg
http://aycu34.webshots.com/image/429...8902793_rs.jpg
http://aycu32.webshots.com/image/410...3424515_rs.jpg
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Well you seem to be a very clever person I must say!
You say you have a month? It would take you a month to learn the basics to do what you are even thinking about.
This program would of taken a team of programers months to create (from first glance).
I am sorry to say, but if what you say with what is needed and the lack of VB programing knowledge, you will have no chance in completing this program in 1 month!
Edit: If anyone has any idea of a quick crash course to get a program up and running, please come in at this point and help, because I can see no way to teach uaeXuae how to do this within a month, and have a working prog at the end.
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Deadline is after a month. I'll try with my instructor to give me more time. The only way to do so is show him what ive done in a month. Then maybe i'll get extra time. Anyways im downloading Visual Basic 2008 Express Edition. So i gues i cant ask anything untill i get it stuck in VB. My first objective is to achieve the goal no matter how the VBA looks like. Simple vb or whatsoever. Later on if i have sometime i'll consider designing the software in a nicer way.
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Wait, you have an instructor who gave you a term project to write an application in VB and you don't even have VB installed or any experience in using VB?
What the hell kind of course is this?
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by Tom Sawyer
Wait, you have an instructor who gave you a term project to write an application in VB and you don't even have VB installed or any experience in using VB?
What the hell kind of course is this?
This course is GP2(Graduation Project 2) for mechanical Engineering.
In Graduation project 1 we achieved many things. Our objective is to customize a tool path for mechanical elements such as spur gears , helical gears.
GP1 was graded as follows:
40% of the grade with the instructor
20% of the grade 5 weekly presentations with the advisor
40% with the final examination comunitee which consists of 3 examiners
two of them are from the mechanical engineering department and the other one is from electrical engineering department.
One question that was asked by the examination comunitee is " How can you say you developed a program and all what we can see is an excel file ? "
In GP2 our instructor told us the feedback he got from the examing comunitee. We are 3 people in a group. My task is to accomplish the Visual Basic part so that when were asked the same question again we defend ourselves. My colleuges are doing their tasks as agreed, where one of my collegues is still looking for applications of spur gears(DC motor , RPM , etc) to show them the use of what were doing. Our instructor gives us hints since its our project and we divide things among us. Since were mechanical engineers well do whatever it takes to finish things on time.
I hope im making sense to you :-)
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Well, if you were a business, I'd say hire a contractor who knows VB. Since you'd need to pay a minimum of about $40/hour to get someone who could write that in a month, that's likely not an option for students.
The steps you need to do are;
1) Build the user interface. Put all the buttons, textboxes and labels on there, so you have the shell you can use to put the programming logic into.
2) Create an OleDbConnection object to pull all the data you need in from Excel to display and then put the logic to process it in one button at a time
3) Drop the diagram. You're not going to go from knowing nothing about VB to being able to code a GDI application that responds to user input within a month. If you try, you're not going to get any of the rest done.
-
Re: [2005] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by Tom Sawyer
2) Create an OleDbConnection object to pull all the data you need in from Excel to display and then put the logic to process it in one button at a time
3) Drop the diagram. You're not going to go from knowing nothing about VB to being able to code a GDI application that responds to user input within a month. If you try, you're not going to get any of the rest done.
Thanks for the heads up man,
Hmmmm we also have to do a presentation regarding VB how did we end up with a program. Print screen tutorial. Im looking for an easy and extremly fast way to cut my way through. :S.
VB 2008 did not finish downloading untill then i will so step 1. But i still dont understand steps 2 & 3. "OleDbConnection object":confused: :confused: Dont i need a flash component installed because the diagram changes with the input. I think the most confusing part is going to be the diagram thingy while the rest is straight forward equations with hidden or internal calculations.
Edit: we finished one presentation we talked about the prototype weve done. The Second and third presentations are going to be about the optimization of the process. The fourth which i consider most important is going to be about the visual basic. So basically The fourth presentation is due on 2nd April. I dont have to really finish the visual basic by then. But at least i must show the advisor what weve been up to lately.So it doesnt really matter if the visual basic is finished by then or not. Most important is that it should be done before the final examination date which is probably by the end of may 28th of may. So that leaves me with like 83 days.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
The OleDbConnection is an object that VB used to read data from an Excel sheet to use it inside of a VB application. You'll use that to grab the information from Excel to then use in your calculations inside of the VB program.
GDI is what VB uses to draw graphics and the like. I don't know much about Flash, but you may be able to use that instead if it does the same thing.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
WOW, all i can say is tough break....
If your course / instructor is telling you that you need to produce something in VB, I would get them to supply you with the program, if you are having problems downloading.
If your excel document uses alot of VBA, you might be able to use some of that code within VB.
At this stage, finish downloading VS 2008 or get from instructor. Totally agree with Tom's first point. Design the interface and go from there.
Another point is to search the forums, you can always find great pieces of knowledge.
Hope this helps
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by Tom Sawyer
The OleDbConnection is an object that VB used to read data from an Excel sheet to use it inside of a VB application. You'll use that to grab the information from Excel to then use in your calculations inside of the VB program.
GDI is what VB uses to draw graphics and the like. I don't know much about Flash, but you may be able to use that instead if it does the same thing.
Thanx a lot. Sorry for not posting here due to some problems with my ISP.
Im back downloading VB 2008 (38 Parts)
http://aycu40.webshots.com/image/460...8096098_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by SonicBoomAu
WOW, all i can say is tough break....
If your course / instructor is telling you that you need to produce something in VB, I would get them to supply you with the program, if you are having problems downloading.
If your excel document uses alot of VBA, you might be able to use some of that code within VB.
At this stage, finish downloading VS 2008 or get from instructor. Totally agree with Tom's first point. Design the interface and go from there.
Another point is to search the forums, you can always find great pieces of knowledge.
Hope this helps
The excel file has 0% visual basic its done with pure excel
eg: ( = sumA1:A3) simple coding.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
OK i managed to install VB 2008 ,, now which option do i choose ?
http://aycu28.webshots.com/image/475...4776222_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Ok can anyone tell me hoe can i do the subscript tip ?
http://aycu07.webshots.com/image/466...1661212_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I built the user interface but where exactly do i start from here ?
http://aycu08.webshots.com/image/443...2635270_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
You want all of this data to create a final product not as you enter the data but as you execute a button press.
So on your form Click and drag a button somewhere useful (Say below all of the Labels and Text Boxes).
Then from there to get the code interface double click on your button, this will bring up the begining of where you need to start for the code.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Don't use the "publish". Go to "security" and "signing" and uncheck everything (don't use one-click signing). You don't want any of those headaches right now and this isn't for commercial use. The built in signing and OneClick is a mega-pain in the rear to muck with when you barely know how to use the front end. Take it from me, I'm also a Mechanical Engineer who just so happened to teach himself enough VB.NET to get stuck doing it for a career. :D
To run the program, just click the green "play" icon in the toolbar above. It should build and run then.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
LOL this is getting interesting anyways i rebuilt the user interface again i had to hit CTRL + SHIFT + S. Anyways i want to save an exe file. Now can anyone guide me through this ?
http://aycu38.webshots.com/image/487...7756266_rs.jpg
http://aycu38.webshots.com/image/487...8496290_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Just click on "Build" on the top menu and select "Build Solution"
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Just click the green button as you said to run the application or press F5. Since you have not writen any code the app will not do anything. You can enter text in your text boxes and click on the button but nothing will happen.
The exe is usually found in the bin directory of your application.
You should not worry about it until your application is complete.
One more thing I would suggest that you name all the objects with meaningfull names so that you can refer to them later on.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by uaeXuae
Thanx tom i tried it many times but no luck
Are you sure? Check in the bin directory of your project and it should be in there. If you haven't made any changes to the program since the last compile, it may not update the Date Modified time, though.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
May I ask, have you actually wrote ANY code for this yet? If you have not all you have is alot of text boxes, labels and a button that you can click, but wont do anything.
You need to double click on the button to bring up another window, this is where you start to write your code.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by Clanguage
Just click the green button as you said to run the application or press F5. Since you have not writen any code the app will not do anything. You can enter text in your text boxes and click on the button but nothing will happen.
The exe is usually found in the bin directory of your application.
You should not worry about it until your application is complete.
One more thing I would suggest that you name all the objects with meaningfull names so that you can refer to them later on.
WoW thanks man :D
Thanks for the tip also :D
Quote:
Originally Posted by Tom Sawyer
Are you sure? Check in the bin directory of your project and it should be in there. If you haven't made any changes to the program since the last compile, it may not update the Date Modified time, though.
http://aycu14.webshots.com/image/457...8348003_rs.jpg
Quote:
Originally Posted by Lerroy_Jenkins
May I ask, have you actually wrote ANY code for this yet? If you have not all you have is alot of text boxes, labels and a button that you can click, but wont do anything.
You need to double click on the button to bring up another window, this is where you start to write your code.
No i havent written any code yet. I will start with that now. But where do you suggest that i write the code in the "Calculate" Button ?. How would i start writing the code similarly like excel ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
do i right click on the TXT box ? and enter a certain code ?
http://www.vbforums.com/
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
You need a comma to seperate the message box prompt from the vbexclamation constant.
vb Code:
PresureA = MsgBox("Pressure angle cannot exceed 25!", vbExclamation, "Error!")
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanx man it works fine :
http://aycu12.webshots.com/image/470...5120072_rs.jpg
But it seems that when a negative value is entered i get the following error:
http://aycu29.webshots.com/image/465...4774258_rs.jpg
vb Code:
Dim PresureA As Integer
If (pa.Text > 25) Or (pa.Text < 0) Then
' Enter the presure angle again
PresureA = MsgBox("Pressure angle cannot exceed 25!", vbExclamation, "Error!")
pa.Text = ""
End If
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
vb Code:
Dim PresureA As Integer
If (pa.Text > 25) Then
pa.Text = 25
PresureA = MsgBox("Pressure angle cannot exceed 25!", vbExclamation, "Error!")
End If
If (pa.Text < 0) Then
pa.Text = 0
PresureA = MsgBox("Pressure angle cannot be less than zero!", vbExclamation, "Error!")
End If
The only problem now is when i enter a negative number the program fails.
http://aycu30.webshots.com/image/485...0141496_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Try
vbnet Code:
Dim PresureA As Integer, dblPa as Double = 0.0
dblPa = Convert.toDouble(pa.text)
If (dblPa> 25) Then
pa.Text = 25
PresureA = MsgBox("Pressure angle cannot exceed 25!", vbExclamation, "Error!")
End If
If (dblPa< 0) Then
pa.Text = 0
PresureA = MsgBox("Pressure angle cannot be less than zero!", vbExclamation, "Error!")
End If
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
This particular field your trying to fill (Pressure Angle) would probably benefit more with a NumericUpDown control. Then you could set it to have a Minimum and Maximum value as well as a starting value.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Will try it now thanks buddy doing some search i found this :
Under these circumstances, if the user entered the number -27,
the control wouldn't accept it because the beginning dash isn't
a number
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
After trying your code i got the following error :
http://img172.imageshack.us/img172/1...tstringhw3.jpg
seems i have to use the "IsNumeric" code something like that
Edit:A code i found but did not understand its logic.
Code:
Private Sub Text1_Change()
If Not ValidateNumeric(Text1.Text) Then
Text1.Text = ""
End If
End Sub
Private Function ValidateNumeric(strText As String) _
As Boolean
ValidateNumeric = CBool(strText = "" _
Or strText = "-" _
Or strText = "-." _
Or strText = "." _
Or IsNumeric(strText))
End Function
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
vb Code:
Dim intTemp As Integer
If Not Integer.TryParse(pa.Text, intTemp) Then
MsgBox("Warning: You entered text instead of a number")
End If
If intTemp > 25 Then
pa.Text = 25
MsgBox("Pressure angle cannot exceed 25!", vbExclamation, "Error!")
ElseIf intTemp < 0 Then
pa.Text = 0
MsgBox("Pressure angle cannot be less than zero!", vbExclamation, "Error!")
End If
The only problem is that i get a warning message when i hit the minus sign - or even when i use backspace i get the warning mesage. is there anyway that i can make exceptions for both the minus sign and the backspace ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Easy use a NumericUpDown Control instead of a text box.
I just realised that you have this in the TextChanged event of the textbox. So what is happening is that when you press the "-" then it tries to change this to a number, and "-" is not a number. If you are going to use textboxes then the easiest way is to validate the textboxes when you click the Calculate button or to validate the text when focus leaves the textbox (Use the pa.LostFocus() event)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
vbnet Code:
Private Sub pa_LostFocus(byval sender as object, byval e as System.EventArgs) handles pa.LostFocus()
if not pa.Text.IsNullOrEmpty(pa.Text) andalso not pa.Text = "" Then
'This checks for blanks in the text box
Dim intPA as Integer = Convert.ToInt32(pa.Text)
if intPA > 25 Then
pa.Text = 25
MessageBox.show("Pressure angle cannot exceed 25 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf intPA < 0 Then
pa.Text = 0
MessageBox.show("Pressure angle cannot be less than 0 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End if
End Sub
You could try this sub procedure. Comment all the TextChanged code out and then add this code.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanx for the code will try it now
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
change this line
vbnet Code:
if not pa.Text.IsNullOrEmpty(pa.Text) andalso not pa.Text = "" Then
to read like this
vbnet Code:
if not string.IsNullOrEmpty(pa.Text) andalso not pa.Text = "" Then
Otherwise you will get an error here.
Also after each of the MessageBox lines you could add another line
This will force that text box to become the one that is active.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
vb Code:
Private Sub pa_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles pa.LostFocus
If Not String.IsNullOrEmpty(pa.Text) AndAlso Not pa.Text = "" Then
'This checks for blanks in the text boxDim intPA as Integer = Convert.ToInt32(pa.Text)
Dim intPA As Integer = Convert.ToInt32(pa.Text)
If intPA > 25 Then
pa.Text = 25
MessageBox.Show("Pressure angle cannot exceed 25 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
pa.Focus()
ElseIf intPA < 0 Then
pa.Text = 0
MessageBox.Show("Pressure angle cannot be less than 0 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
pa.Focus()
End If
End If
i entered the following code i still want to modify the code so that when the calculate button and text is entered i get a msgbox saying
if text was entered
msgbox "Text was entered!"
pa.text = Clear
end if
how am i able to do so ?
http://img526.imageshack.us/img526/9585/a1yl2.jpg
http://img142.imageshack.us/img142/6572/a2pu7.jpg
http://img341.imageshack.us/img341/6649/a3ef2.jpg
http://img253.imageshack.us/img253/9002/a4sv0.jpg
http://img405.imageshack.us/img405/3791/a5gf4.jpg
http://img135.imageshack.us/img135/637/a6ky6.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Finally found the solution and works like charm
vb Code:
Private Sub pa_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles pa.LostFocus
Dim intPA As Integer
If Not String.IsNullOrEmpty(pa.Text) AndAlso Not pa.Text = "" Then
If Not Integer.TryParse(pa.Text, intPA) Then
'Text was entered
MessageBox.Show("Text was entered!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Error)
pa.Text = ""
Else
'This checks for blanks in the text boxDim
If intPA > 25 Then
pa.Text = 25
MessageBox.Show("Pressure angle cannot exceed 25 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
pa.Focus()
ElseIf intPA < 0 Then
pa.Text = 0
MessageBox.Show("Pressure angle cannot be less than 0 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
pa.Focus()
End If
End If
End If
End Sub
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
If im to modify the above code and let it accept decimals what should i modify i tried the following but no luck:
vb Code:
Dim intPA As Double = 0.0
intPA = Convert.ToDouble(pa.Text)
If Not String.IsNullOrEmpty(pa.Text) AndAlso Not pa.Text = "" Then
If Not Integer.TryParse(pa.Text, intPA) Then
'Text was entered
MessageBox.Show("Text was entered!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Error)
pa.Text = ""
Else
'This checks for blanks in the text boxDim
If intPA > 25 Then
pa.Text = 25
MessageBox.Show("Pressure angle cannot exceed 25 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
pa.Focus()
ElseIf intPA < 0 Then
pa.Text = 0
MessageBox.Show("Pressure angle cannot be less than 0 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
pa.Focus()
End If
End If
End If
End Sub
http://img525.imageshack.us/img525/3500/decimallp1.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
The simple thing is do as demausdauth says: Delete the "pa" control from your form. Replace it with a NumericalUpDown control. This way, it's impossible to put in a non-numeric value. If you name the NumericalUpDown the same thing as your Textbox "pa", then you get your value with: pa.Value
This is a case of "Use the right tool for the right job!". Use Textboxes for "Text", use NumericalUpDowns for "Numbers".
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Done But the problem is i want to take the value from that NUD and do some invisible calculations which i want to be taken to a new forum or what i usually call the next page. So for that to happen shall i use a textbox ? to carry the answer invisible after doing some calculation. or is there something better besides the textbox. As an input i'll use NUD for all but as an output what shall i use ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
No, that's what variables are for.
Make a variable:
Dim myVariable as Double
and work with it (random garbage equation):
myVariable = ((intPA + 700) /90) - (intAA * 2)^2
Then assign it back to a control:
NumericUpDown1.Value = myVariable
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
You can use the Click event of the button to perform all your calculations. What we need to know now is what are you going to do with the values that you calculate.
vbnet Code:
Private Sub Calculate(byval sender as object, byval e as system.eventargs) handles 'Whatever the button name is .Click
'Preform your Calculations here
'If you are going to pass these values to another screen then we need to
'decide how to pass them.
' method1
Dim frmObject as New frmNextForm(value1, value2, value3, value4, value5)
frmObject.show()
'method2
' this one requires that frmNextForm has variables declared as public on it
Dim frmObject as New frmNextForm()
frmObject.Value1 = value1
frmObject.Value2 = value2
frmObject.Value3 = value3
frmObject.Value4 = value4
frmObject.Value5 = value5
frmObject.Show()
' then you will probably want to close the first screen and leave the
' second one open. Make sure to change the properties of the project
' under the Application tab -> Shutdown mode to When last form closes
Me.Close()
I know there are other methods for passing values and there are better ways, but one of these methods I think is the easiest and quickest way to get'er done. :)
Your next form will need something like this:
Method 1
Declare 5 variables above the Visual Studio generated code. In my case I am using Value1, Value2, etc...
vbnet Code:
Dim Value1 as decimal = 0.0, Value2 as decimal = 0.0, Value3 as decimal = 0.0, Value4 as decimal = 0.0, Value5 as decimal = 0.0
Public Sub New(byval PassValue1 as Decimal, byval PassValue2 as decimal, byval PassValue3 as decimal, byval PassValue4 as decimal, byval PassValue5 as decimal)
' I specify them as decimal because I don't know what type they would be
' You would have to specify whatever the type you want to pass
Value1 = PassValue1
Value2 = PassValue2
Value3 = PassValue3
Value4 = PassValue4
Value5 = PassValue5
End Sub
There now your values have been passed by method 1 and you will be able to use them on the next form.
Method 2
Declare 5 variables above the Visual Studio generated code. In my case I am using Value1, Value2, etc...
vbnet Code:
Public Value1 as decimal = 0.0
Public Value2 as decimal = 0.0
Public Value3 as decimal = 0.0
Public Value4 as decimal = 0.0
Public Value5 as decimal = 0.0
There now your values have been passed by method 2 and you will be able to use them on the next form.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by demausdauth
You can use the Click event of the button to perform all your calculations. What we need to know now is what are you going to do with the values that you calculate.
I believe he's going to take his input numbers, use them to create a table that calculates the perimeter of each gear, attaches an offset to that perimeter, figure out the X-Y coordinates for various discrete intervals along that curve, then use those X-Y coordinates to write lines of code to command a CNC machine to cut the gear out.
Each line of code would be "go to point X-Y", and the machine would obey. If his points are fine enough, it can essentially cut curves as well. The offset is because the cutting bit on the machine has thickness (a 1" diameter cutter would need a 0.5" offset since your position is the center of the tool).
Depending on how fine he slices his computation table these are all easily achievable.
The program's purpose is simple in the end: Input a handful of variables -> Output a file containing CNC machine instructions for how to cut a set of shapes.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by demausdauth
You can use the Click event of the button to perform all your calculations. What we need to know now is what are you going to do with the values that you calculate.
vbnet Code:
Private Sub Calculate(byval sender as object, byval e as system.eventargs) handles 'Whatever the button name is .Click
'Preform your Calculations here
'If you are going to pass these values to another screen then we need to
'decide how to pass them.
' method1
Dim frmObject as New frmNextForm(value1, value2, value3, value4, value5)
frmObject.show()
'method2
' this one requires that frmNextForm has variables declared as public on it
Dim frmObject as New frmNextForm()
frmObject.Value1 = value1
frmObject.Value2 = value2
frmObject.Value3 = value3
frmObject.Value4 = value4
frmObject.Value5 = value5
frmObject.Show()
' then you will probably want to close the first screen and leave the
' second one open. Make sure to change the properties of the project
' under the Application tab -> Shutdown mode to When last form closes
Me.Close()
I know there are other methods for passing values and there are better ways, but one of these methods I think is the easiest and quickest way to get'er done. :)
Your next form will need something like this:
Method 1
Declare 5 variables above the Visual Studio generated code. In my case I am using Value1, Value2, etc...
vbnet Code:
Dim Value1 as decimal = 0.0, Value2 as decimal = 0.0, Value3 as decimal = 0.0, Value4 as decimal = 0.0, Value5 as decimal = 0.0
Public Sub New(byval PassValue1 as Decimal, byval PassValue2 as decimal, byval PassValue3 as decimal, byval PassValue4 as decimal, byval PassValue5 as decimal)
' I specify them as decimal because I don't know what type they would be
' You would have to specify whatever the type you want to pass
Value1 = PassValue1
Value2 = PassValue2
Value3 = PassValue3
Value4 = PassValue4
Value5 = PassValue5
End Sub
There now your values have been passed by method 1 and you will be able to use them on the next form.
Method 2
Declare 5 variables above the Visual Studio generated code. In my case I am using Value1, Value2, etc...
vbnet Code:
Public Value1 as decimal = 0.0
Public Value2 as decimal = 0.0
Public Value3 as decimal = 0.0
Public Value4 as decimal = 0.0
Public Value5 as decimal = 0.0
There now your values have been passed by method 2 and you will be able to use them on the next form.
Very valuable post to me THANKS!
Thanks ive been away for the past day. How do i open another window and close the active window when the button calculate is clicked ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by demausdauth
vbnet Code:
Private Sub Calculate(byval sender as object, byval e as system.eventargs) handles 'Whatever the button name is .Click
'Preform your Calculations here
'If you are going to pass these values to another screen then we need to
'decide how to pass them.
' method1
Dim frmObject as New frmNextForm(value1, value2, value3, value4, value5)
frmObject.show()
'method2
' this one requires that frmNextForm has variables declared as public on it
Dim frmObject as New frmNextForm()
frmObject.Value1 = value1
frmObject.Value2 = value2
frmObject.Value3 = value3
frmObject.Value4 = value4
frmObject.Value5 = value5
frmObject.Show()
' then you will probably want to close the first screen and leave the
' second one open. Make sure to change the properties of the project
' under the Application tab -> Shutdown mode to When last form closes
Me.Close()
End Sub
(I edited my quote and added the End Sub that I forgot in the original posting :))
Line 8 (Line 13) will create space in memory for the new form.
Line 9 (Line 19) will cause the new form to be shown and Line 24 will cause the current form ( the one that you have just entered values on ) to close.
Remember that in this sub procedure I am using two different methods to achieve the same thing. You will need to choose one and go with.
I am not exactly sure where the Application settings are in VS2008 but I would think that if you right-click on the project name in the Solution Explorer that you should be able to click on Properties. From there you should be able to find the Application tab, then find the Shutdown mode. This has to be changed to When the Last Form Closes or when the program hits the Me.Close() the application will end.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanks Buddy. Im trying to do this passing method but no luck so far.
1.I want The function of the "Calculate" Button to be as follows.Take value from NUD and send them to the third form.
http://aycu19.webshots.com/image/499...0305776_rs.jpg
2. Open the second form ( which i know how to do ) & Do apply this law in the third formCommon_Features. 1/(whatever NUD value is selected in form1).
This is the Second form.
http://aycu09.webshots.com/image/458...6578283_rs.jpg
3. See the number 0.25 for example if the NUD of diametral pitch was set to 4. [1/4]=0.25
http://aycu19.webshots.com/image/499...0020895_rs.jpg
I tried following up your tutorial but i always get error mesages. May you ut me on the correct track again please ?
Edit:I am sending the value into one form then showing a different form.
Purpose is that the different form consists of 3 tables so i set them into buttons. each button will open a table.I can read many options in my mind. Do everything in the Calculation Button ?(form1) or Send values to second form then from second to third to mylabel ?
If you were in my place what approach will you use ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Ok heres what ive done. In form1 i had this code
Public Class Form1
Code:
Public Shared Diametral_Pitch As String
and in the NUD controller i had this code
Code:
Private Sub dp_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dp.ValueChanged
Diametral_Pitch = dp.Text
End Sub
I was testing to see if im getting the correct value.
In the Second form i had a label.
and the following code
Code:
Private Sub second_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = Form1.Diametral_Pitch
End Sub
End Class
The problem was that the value was less than the NUD value by 1. And after i hit the back button and change the value of the NUD and hit the calculate button. The previous values remains so in my case the number 6 remains forever untill i terminate the program and run again.
http://img149.imageshack.us/img149/4335/19173162yh3.jpg
http://img151.imageshack.us/img151/6294/97406613oc2.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Now i tried putting the code in the calculation Button
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Diametral_Pitch = dp.Text
second.Show()
Me.Hide()
End Sub
When i hit the calculate button i get the same exact number as in the NUD.
I hit the "back" button change the value of the NUD and hit the "Calculate" Button and no changes take effect. So now it works only for one time. i want to change infinite number of times.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I solved the problem by doing nothing in form2 eveything was done in form1.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Diametral_Pitch = dp.Text
Common_Features.Distance_Center.Text = (1 / (Form1.Diametral_Pitch))
second.Show()
Me.Hide()
End Sub
Works fine back and forth.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Code:
If Diametral_Pitch < 0 Then
Common_Features.Dedendum.Text = (1.25 / Diametral_Pitch).ToString
ElseIf Diametral_Pitch > 0 Then
Common_Features.Dedendum.Text = ((1.2 / Diametral_Pitch) + 0.002).ToString
End If
The only problem is that the answer i get from VB is 0.302 while the answer i get when i use my calculater is 0.3125
The equation is as follows 1.25/4 So why am i getting 0.302 ?