-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Now after that loop is run i'll want to convert this data into a a drawing. Now how do i say take all 8 colums and take them to a different form. and then start drawing Each X,Y together.
Base (X,Y)
Pitch (X,Y)
Root(X,Y)
Outer(X,Y)
with a key at the top 4 different colors for each circle.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Well, you're going to need some type of graphing object. I doubt you want to draw it directly on the form. Unfortunately, I don't have much experience with that.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
This is some code i got from other people but i have failed to implement with the previous ( 8 array code ).Would Appreaciate Any One stepping forward to help me out.
I found this article:
Article 1
Article 2
Quote:
Originally Posted by wild_bill
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics = Me.CreateGraphics
Dim p As New Pen(Color.Pink, 1)
'by default the grid starts in the upper left hand corner (0)
'we want to use the center of the form as (0)
Dim centerX As Single = Convert.ToSingle(Me.Width / 2)
Dim centerY As Single = Convert.ToSingle(Me.Height / 2)
'load an object to store your points
'note you will need to load many more points to see your graphic take shape
Dim xs As New List(Of Single)
Dim ys As New List(Of Single)
xs.Add(119.063)
xs.Add(119.391)
xs.Add(120.306)
xs.Add(120.87)
xs.Add(121.368)
ys.Add(-10)
ys.Add(-10)
ys.Add(-9.964)
ys.Add(-9.917)
ys.Add(-9.863)
'draw lines in between points
For i As Integer = 0 To xs.Count - 2
Dim x1 As Single = centerX + xs(i)
Dim y1 As Single = centerY + ys(i)
Dim x2 As Single = centerX + xs(i + 1)
Dim y2 As Single = centerY + ys(i + 1)
g.DrawLine(p, x1, y1, x2, y2)
Next
End Sub
Quote:
Originally Posted by wild_bill
vb Code:
Dim scale As Single = 1.2
'draw lines in between points
For i As Integer = 0 To xs.Count - 2
Dim x1 As Single = centerX + (xs(i) * scale)
Dim y1 As Single = centerY + (ys(i) * scale)
Dim x2 As Single = centerX + (xs(i + 1) * scale)
Dim y2 As Single = centerY + (ys(i + 1) * scale)
g.DrawLine(p, x1, y1, x2, y2)
Next
Quote:
Originally Posted by jal2
The graphics class allows you to draw (either on paper or to the screen) at specified X,Y points on the drawing surface using the drawLine command. A Graphics object IS in fact a drawing surface (thus it draws upon itself). Depending on what surface you want to use, you will either create the Grapics object yourself or use the one provided by .Net. For example .Net provides one in the Paint event if you add that event to your code:
vb Code:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Define a rectangle.
Dim r As New Rectangle(25, 25, 200, 150)
' Draw it with a black pen.
e.Graphics.DrawRectangle(Pens.Black, r)
' Add some text.
Dim f As New Font("Times", 24)
e.Graphics.DrawString("Sample text", f, Brushes.Red, 70, 80)
End Sub
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thar draws directly on the form, but the big problem will be one of coordinate values. Granted, you are going +/- 135 or so coordinate wise so it may be alright.
Look at JUST the loop in your first example. You can use something similar to that. You have X and Y coordinates for everything.
You just need to add an offset to your numbers so the circle is drawn in the center of the form, and not centered in the upper left corner.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I would approach it by saying take all values from the previous X & Y's
How do i say Take those values and store them in this new Drawing Code ...:S
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
You got a loop from my previous example. Make it loop from 0 to 72 times with no "step". Because of that loop, you got a control variable that's counting every cycle. I used the variable "i".
Now, inside the loop, you can put in your array lines:
BaseX(i) and BaseY(i) is the Base X,Y coordinates for the first pass...
Now you just have to send them somewhere... how about to the Base X, Y coordinates on the second pass? Well, you're on the first pass, you can't wait for the second pass, so just use:
j = i+1
BaseX(j) and BaseY(j)
Ok, now draw the line. Draw the line from coordinate: BaseX(i), BaseY(i) to coordinate BaseX(j), BaseY(j).
There's ONE problem with this... what happens when the loop gets to pass 72? There is no i+1. What do you do? Send it back to zero:
If i+1 > 72 then
j = 0
Else
j = i+1
-
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
I have been using VB 6 since 1999 and I just switched to VB 2008 XE last december. I have no formal training and since the first of last december(2007)
I have been working approx. 40 hours a week on converting my VB 6 database to VB 2008 XE and I am only about 50% thru.
My congrats to you if you can even come close to completion of your project in the time frame you are talking about.
Quote:
Originally Posted by uaeXuae
After trying your code i got the following error :
http://www.vbforums.com/
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
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Wow, I'm truly impressed uaeXuae!! That's one heck of a milestone. Your program looks impressive!
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanx buddy :-)
Im planning on moving the Input Machining Parameters over to when the "Save CNC Code" Button is Clicked. So that the header cnc code for both the Gear and Pinion is entered individually.
Random CNC Header code
BEGIN PGM FILENAE MM
BLK FORM 0.1 Z X+0 Y+0 Z – 40
BLK FORM 0.2 X+100 Y+100 Z+0
TOOL DEF 2 L+0 R+7
TOOL CALL 2 Z S1000
L M6
X+30 Y+30 R0 F100 M3
L Z+5 F 100
L Z-5 F 100
L Z+100 R0 F 100 M5
END PGM FILENAME MM
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Congrats uaeXuae. I have been following your progres sincce your first cry for help and I am truly impressed at the way you attacked the problem and how you are delivering a solution. Your app looks great and I think that you have a bright future in the field of Engineering. I have the feeling that after everything is said and done and when you reflect back you will realize how much fun it truly was to take on this challenge.
Good luck to you :):):)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanks for your nice words. Frankly speaking i wasnt sure i was able to do that or even start with it or where to start tackling. Many thanks to you and to all of those who helped me or gave me hints on where to look or what to do. Thanks guys gr8 forum love it.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Does anyone have any articles about saving picture as JPEG ?
http://www.vbforums.com/
If im to do a save picture as for this forum. Is it more like photoshop ? Layers ? Is there a simple way to extract the whole form into a JPEG ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
That is truly amazing and astounding UaeXuae.
You have managed to do so well on this (sorry for the late Congratulations)!
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanx buddy for your sweet words.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
How about a print screen function to save the form ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
DO you want this in the code? Or just a way to make a copy of what is on the screen of just hte form?
Because I think it is Alt + Printscreen to get the current window.
Is that what you are after?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
heres what i want to do.
i want to add a button somewhere here.
http://www.vbforums.com/
When that button is clicked. The print screen function will caputure the form and i'll be getting something like:
http://aycu16.webshots.com/image/514...5036518_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I found this code from google but did not know how to implement.
vb Code:
Private Shared Function BitBlt( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Integer _
) As Boolean
End Function
Private Shared SRCCOPY As Integer = &HCC0020
Private Sub SaveFormToFile(ByVal sourceForm As Form, ByVal filename As String)
Dim formGraphics As Graphics = sourceForm.CreateGraphics()
Dim
bufferRect = sourceForm.ClientRectangle
Dim buffer As Image = New Bitmap(bufferRect.Width, bufferRect.Height, formGraphics)
Dim bufferGraphics As Graphics = Graphics.FromImage(buffer)
Dim formDC As IntPtr = formGraphics.GetHdc()
Dim bufferDC As IntPtr = bufferGraphics.GetHdc()
BitBlt(bufferDC, 0, 0, bufferRect.Width, bufferRect.Height, formDC, 0, 0, SRCCOPY)
bufferGraphics.ReleaseHdc(bufferDC)
formGraphics.ReleaseHdc(formDC)
bufferGraphics.Dispose()
formGraphics.Dispose()
buffer.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg)
buffer.Dispose()
End Sub
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Bah... don't need nearly that much...
Here:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bmp As New Bitmap(Me.Width, Me.Height)
Dim sdlg As New SaveFileDialog
Me.DrawToBitmap(bmp, New Rectangle(0, 0, Me.Width, Me.Height))
sdlg.Filter = "Jpeg File|*.jpg"
If sdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
bmp.Save(sdlg.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
End If
End Sub
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanx Problem solved :-).
http://aycu03.webshots.com/image/514...9674773_rs.jpg
http://aycu03.webshots.com/image/514...6101512_rs.jpg
http://aycu01.webshots.com/image/499...1316614_rs.jpg
http://img522.imageshack.us/img522/3371/yeszm1.png
================================================
================================================
How do i make my program work for 5 times and then Expire and will never work again ? In which i'll have to rebuild a new one using VB so that it will work for another 5 times more.The approach i used is as follows.
I created a text file with the name zxs.txt and set it as a counter for the program:
http://aycu02.webshots.com/image/504...3705204_rs.jpg
http://aycu02.webshots.com/image/493...5759376_rs.jpg
http://aycu16.webshots.com/image/484...5848467_rs.jpg
http://aycu31.webshots.com/image/494...1460352_rs.jpg
http://aycu38.webshots.com/image/481...5605232_rs.jpg
http://aycu17.webshots.com/image/501...9991303_rs.jpg
So now to make the program open i'll have to open that text file and set the value to zero. Now what im after is:
I want the program to run for 5 times, when it expires i want to manually create the zxs.txt file run the program so that the number of trials is back to zero."Then i run the program so that it resets the trial from the text file".Then safely i can delete the text file , moreover i want to make this step as a secret. Now what happens when i run the program without that file is:
http://aycu28.webshots.com/image/486...3645200_rs.jpg
Instead i want the program to run and make the zxs.txt a secret way to reset the program. If anyone how any idea how to do so please come forward. Any other suggestions are welcomed.
-
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
Rather than storing in a text file, which can easily be discovered and hacked, store the number in an internal settings file instead.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Yea, and you're going to need some kind of license coding as well. There's really no good way around it.
An example I have is a program that has an XML config file. I chose this way so my program would be licensed to the whole computer rather than the user account using it (a lot of internal settings that VB can do automatically for you are tied to the windows login).
When it starts up it looks for the license code in the config.xml file. If it's not there or if it's wrong, then it checks in the computer's registry for a hidden key. If the key isn't there, it makes it and sets it to an encrypted "1", for first run. If the key is already there, it decrypts it and gets how many runs the program has been through and advances it by one. If it's higher than my limit, it'll refuse to work until you put in the license key.
You can find code examples of simple strong cryptography in my sig. If you play with them a little bit you can easily cobble together your own scheme you want to use to secure your program from casual hackers. Nothing is going to stop a dedicated hacker from cracking the program though.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanx buddy if you have some articles or examples id be thankful :-)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
What is the best way to print the code on A4 paper. I get three options only , which one is the best. Snag it will save the code as JPEG this means the text would be treated as an image.
Anyways what im really up to is how do i print the entire source code ?
http://aycu08.webshots.com/image/506...7930049_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
VSNETcodePrint2005 seems the best printing software !! Since im using .NET 2008 i had to download the VSNETcodePrint2008.
I found a full working copy of VSNETcodePrint2005 compatible with .NET 2005.But its not compatible with .NET 2008.ill have to install .NET 2005 (Downloading in Progress :D)
Anyways here is the trial version for .NET 2008 ( Gotta say love the index)
http://www.vbforums.com/
http://www.vbforums.com/
http://www.vbforums.com/
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
When i intalled Vb 2005 my solution didnt work because my program was built using Vb 2008 so i have to convert the solution to 2005 so it could open and then i can use code print.
Quote:
Originally Posted by Derek Smyth
Here is a tool that will patch a VS2008 solution file (*.sln) and will produce a VS2005 solution file. You don't need to delete the VS2008 solution file, use that at home, and use the VS2005 for when your at school.
VS2008ToVS2005Patcher.zip
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Hi
There are two missing things in the project. Im already done devloping the first missing thing.
Now Basically heres what i want to do:
http://img214.imageshack.us/img214/6742/49799547vg8.jpg
1-Select the Material Name from the Combo Box
2-(Build an If statement; for instanse if the mild steel is selected and the Feed tooth is 0.3 then my value(KC) would be 1820.
3-When the Calculate Button Is hit this is what i want to happen, The Gearsafety.value = (declared variable) where the declared variable would be a mathematical Equation. Example
Dim Calculate as Double
Calculate = Tool Diamater * Depth of Cut * vf * KC ; where the KC is 1820.
http://img329.imageshack.us/img329/1259/26956386ns5.jpg
Now continuing the previous code:
If calcualte < GearMaxpower.value then
Gearsafety.value= "safe"
ele
Gearsafety.value "unsafe"
Now my Question is how would i build an if statement for the combo box for all the materials.
I think its :
If item1.value = true & GearFeedPerTooth=0.1 Then KC = 2200 else if item1.value = true & GearFeedPerTooth=0.2 Then KC = 1950...................................
Then Item2.value = true.....................................
Then Item 3.........
May you kindly tell me the exact code regarding the selection of the combo box items ? and an easier procedure if available ?
Also If I set the control ’ s Sorted property to True , the ComboBox lists its choices in sorted order , will that affect the coding and result in error values ?
Heres my attempt:
Private
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y, z AsDouble
x = (ToolDiameter * (Math.PI) * GearSpindleSpeed.Value) / 1000
GearVc.Text = x
y = GearFeedPerTooth.Value * GearTeethCutter.Value * GearSpindleSpeed.Value
GearVf.Text = y
z = (y * GearDepthCutZ.Value * ToolDiameter) / 1000
GearMrr.Text = z
Dim KC, Calculate AsDouble
If GearMaterialSelection.SelectedItem = "Mild steel" & GearFeedPerTooth.Value = 0.1 Then
KC = 2200
ElseIf GearMaterialSelection.SelectedItem = "Mild steel" & GearFeedPerTooth.Value = 0.2 Then
KC = 1950
ElseIf GearMaterialSelection.SelectedItem = "Mild steel" & GearFeedPerTooth.Value = 0.3 Then
KC = 1820
ElseIf GearMaterialSelection.SelectedItem = "Mild steel" & GearFeedPerTooth.Value = 0.4 Then
KC = 1700
ElseIf GearMaterialSelection.SelectedItem = "Mild steel" & GearFeedPerTooth.Value = 0.6 Then
KC = 1580
EndIf
Calculate = (ToolDiameter * GearDepthCutZ.Value * y * KC) / (1000000 * 60 * 0.9)
GearSafety.Text = Calculate
'If Calculate < GearmaxPower.Value Then
'GearSafety.Text = "Safe"
'Else
'GearSafety.Text = "UnSafe"
'End If
EndSub
I disabled the last 4 lines to see what value fo i get but it keeps giving me a zero.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I edited this line to see if all the code was fine.
Calculate = (ToolDiameter * GearDepthCutZ.Value * y * KC) / (1000000 * 60 * 0.9)
Removed KC and i input an integer and the calculation was done.
So it Seems that KC is not being stored and carried forward form the IF .... ELSEIF statement.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Now the value of Mild Steel is being Selected properly. Now Case "Medium steel".ToUpper KC values seem not to be selected and they return a "0". Is the line code correct ?
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y, z, KC, Calculate As Double
x = (ToolDiameter * (Math.PI) * GearSpindleSpeed.Value) / 1000
GearVc.Text = x
y = GearFeedPerTooth.Value * GearTeethCutter.Value * GearSpindleSpeed.Value
GearVf.Text = y
z = (y * GearDepthCutZ.Value * ToolDiameter) / 1000
GearMrr.Text = z
Select Case GearMaterialSelection.SelectedItem.ToString.ToUpper
Case "Mild steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 2200
Case 0.2D
KC = 1950
Case 0.3D
KC = 1820
Case 0.4D
KC = 1700
Case 0.6D
KC = 1580
Case "Medium steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 1980
Case 0.2D
KC = 1800
Case 0.3D
KC = 1730
Case 0.4D
KC = 1600
Case 0.6D
KC = 1570
Case "Hard steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 2520
Case 0.2D
KC = 2200
Case 0.3D
KC = 2040
Case 0.4D
KC = 1850
Case 0.6D
KC = 1740
Case Else
' a safety function here for all unwritten GearFeedPerTooth values
End Select
End Select
End Select
'a safety function here for all unwritten GearMaterialSelection values
End Select
Calculate = (ToolDiameter * GearDepthCutZ.Value * GearVf.Text * KC) / (1000000 * 60 * 0.9)
GearSafety.Text = Calculate
End Sub
'End If
'Tool(steel)
'Chrome manganese steel
'Chrome molybdenum steel
'Nickel chrome molybdenum steel
'Cast(iron)
'Meehanite cast iron
'Gray cast iron
'Hard Cast Iron
'Brass()
'light(Alloy(Al - Mg))
'Light(alloy(Al - Si))
'If Calculate < GearmaxPower.Value Then
'GearSafety.Text = "Safe"
'Else
'GearSafety.Text = "UnSafe"
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
You need an "End Select" right before: Case "Medium steel".ToUpper
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanx for the Tip Jenner
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y, z, KC, Calculate, i As Double
x = (ToolDiameter * (Math.PI) * GearSpindleSpeed.Value) / 1000
GearVc.Text = x
y = GearFeedPerTooth.Value * GearTeethCutter.Value * GearSpindleSpeed.Value
GearVf.Text = y
z = (y * GearDepthCutZ.Value * ToolDiameter) / 1000
GearMrr.Text = z
Select Case GearMaterialSelection.SelectedItem.ToString.ToUpper
Case "Mild steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 2200
Case 0.2D
KC = 1950
Case 0.3D
KC = 1820
Case 0.4D
KC = 1700
Case 0.6D
KC = 1580
Case Else
For i.(D) = 0.1 To 10000 + ( How do i rite the code for Skip 0.1D,0.2D,0.3D,0.4D,0.6D)
step = 0.1
Next
KC = ""
End Select
Case "Medium steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 1980
Case 0.2D
KC = 1800
Case 0.3D
KC = 1730
Case 0.4D
KC = 1600
Case 0.6D
KC = 1570
Case Else
For i.(D) = 0.1 To 10000 + ( How do i rite the code for Skip 0.1D,0.2D,0.3D,0.4D,0.6D)
step = 0.1
Next
KC = ""
End Select
Now regarding the Case Else ... Im getting Three Errors:
1-Name 'D' is not declared.
2-Syntax error.
3-Identifier expected.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Don't worry about skipping 0.1D, 0.2D... if it got Case Else, it's not one of those. The Select Case would have exited before it got to Case Else if it was one of those.
For the loop, use integers, and when you need to figure, divide i by 10.
Code:
For i as Integer = 1 to 100000
'Use i/10 for anything you need to do.
Next
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanks Jenner. Ive used the following Code:
Code:
Select Case GearMaterialSelection.SelectedItem.ToString.ToUpper
Case "Mild steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 2200
Case 0.2D
KC = 1950
Case 0.3D
KC = 1820
Case 0.4D
KC = 1700
Case 0.6D
KC = 1580
Case Else
For i As Integer = 0 To 100000
(i/10)D
KC = ""
Next
End Select
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
CDbl(i)/10D would be better, so all your math is done with floating point arithmetic.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Heres my working code but ive got some questions.
Now as you can see for the else case i chose a value for KC to be 0.
after the selection is done, the following code is executed:
Code:
'Take the value of KC no matter what it was proceed with the calcluation
Calculate = (ToolDiameter * GearDepthCutZ.Value * GearVf.Text * KC) / (1000000 * 60 * 0.9)
GearSafety.Text = Calculate
'Now if KC=0 the execute the following code else dont.
If KC = 0 Then
GearSafety.Text = ""
End If
Code:
Dim x, y, z, KC, Calculate As Double
x = (ToolDiameter * (Math.PI) * GearSpindleSpeed.Value) / 1000
GearVc.Text = x
y = GearFeedPerTooth.Value * GearTeethCutter.Value * GearSpindleSpeed.Value
GearVf.Text = y
z = (y * GearDepthCutZ.Value * ToolDiameter) / 1000
GearMrr.Text = z
Select Case GearMaterialSelection.SelectedItem.ToString.ToUpper
Case "Mild steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 2200
Case 0.2D
KC = 1950
Case 0.3D
KC = 1820
Case 0.4D
KC = 1700
Case 0.6D
KC = 1580
Case Else
For i As Double = 0.7 To 10000 Step 0.1
KC = 0
Next
End Select
Case "Medium steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 1980
Case 0.2D
KC = 1800
Case 0.3D
KC = 1730
Case 0.4D
KC = 1600
Case 0.6D
KC = 1570
Case Else
For i As Double = 0.7 To 10000 Step 0.1
KC = 0
Next
End Select
Calculate = (ToolDiameter * GearDepthCutZ.Value * GearVf.Text * KC) / (1000000 * 60 * 0.9)
GearSafety.Text = Calculate
If KC = 0 Then
GearSafety.Text = ""
End If
'If Calculate < GearmaxPower.Value Then
'GearSafety.Text = "Safe"
'Else
'GearSafety.Text = "UnSafe"
'End If
End Sub
I tried modifying the code for KC instead of 0 i Said " "
Code:
Select Case GearMaterialSelection.SelectedItem.ToString.ToUpper
Case "Mild steel".ToUpper
Select Case GearFeedPerTooth.Value
Case 0.1D
KC = 2200
Case 0.2D
KC = 1950
Case 0.3D
KC = 1820
Case 0.4D
KC = 1700
Case 0.6D
KC = 1580
Case Else
For i As Double = 0.7 To 10000 Step 0.1
KC = ""
Next
End Select
Which returned an error Conversion From string"" to type Double is not valid Because at the bottom of the code the calculation cant take place.
Code:
Calculate = (ToolDiameter * GearDepthCutZ.Value * GearVf.Text * KC) / (1000000 * 60 * 0.9)
KC is "".
1-I dont want to use KC = 0 i want to change it to "" and let the code work. How am i able to do so ?
2-Regarding the Material Selection Combo Box can is there anyway to get rid ofthe Null Expected Error ?
For instance if the GearMaterialSelection........ = Null then
Vcg.text=""
Vfg.text=""
GearSafety.text=""
MsgBox("Please Select a Material First", MsgBoxStyle.Information)
or how do i set the combobox to mild steel, Is is similar to the NUD where you can select the desired value ?
3-
Code:
For i As Double = 0.7 To 10000 Step 0.1
.
What im trying to say how did the program execute the following code
Code:
If KC = 0 Then
GearSafety.Text = ""
End If
when the value 0.5 was selected.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
1) KC is a double, you can't. It MUST be a number. you can do this:
Code:
'Take the value of KC no matter what it was proceed with the calcluation
Calculate = (ToolDiameter * GearDepthCutZ.Value * CDbl(GearVf.Text) * KC) / 54000000
If KC = 0 Then
GearSafety.Text = ""
Else
GearSafety.Text = Calculate
End If
Why don't you want KC to be 0?
2) Yes, just set the Text to Mild steel to start and all your variables to default to the variables for Mild steel
3) Why do you have this:
For i As Double = 0.7 To 10000 Step 0.1? It doesn't do anything.
This is why:
Code:
Select Case GearFeedPerTooth.Value '<-- = 0.5
Case 0.1D '<-- No...
KC = 2200
Case 0.2D '<-- No...
KC = 1950
Case 0.3D '<-- No...
KC = 1820
Case 0.4D '<-- No...
KC = 1700
Case 0.6D '<-- No...
KC = 1580
Case Else '<-- Yes...
KC = 0 '<-- Set KC to 0
End Select