Hallo,
I have a problem, I do not know how to convert some data from my visual basic 2005 program into a excel file. Can you please tell me what to do?
5 2512
Hi. The first thing to do is post the code you have already and point out where it is that you need help
Hi. The first thing to do is post the code you have already and point out where it is that you need help
- Public Class Form1
-
Dim g As Double = -9.81 'Gravity
-
-
Function Find_Verical_Velocity(ByVal Vy As Double, ByVal mass As Double, ByVal drag_y As Double) As Double
-
-
If Vy > 0 Then
-
Vy = Vy + ((g - drag_y / mass) * 0.01) 'The equation that gives the velocity is V=Vo-gt
-
Else
-
Vy = Vy + ((g + drag_y / mass) * 0.01)
-
End If
-
-
-
Return (Vy) 'Returns the vertical velocity
-
-
End Function
-
Function Find_Horizontal_Velocity(ByVal Vx As Double, ByVal mass As Double, ByVal drag_x As Double) As Double
-
-
Vx = Vx + (-(drag_x / mass) * 0.01)
-
-
Return (Vx)
-
-
End Function
-
-
Function Find_Distance(ByVal Vx As Double) As Double
-
-
Static Distance As Double = 0
-
-
Distance = Distance + (Vx * 0.01)
-
-
Return (Distance)
-
-
End Function
-
-
Function Find_Height(ByVal Vy As Double) As Double
-
Static Height As Double = 0
-
-
Height = Height + (Vy * 0.01)
-
-
Return (Height)
-
-
End Function
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
Dim mass As Double = CInt(TextBox1.Text)
-
Dim angle As Double = CInt(TextBox2.Text)
-
Dim initial_velocity As Double = CInt(TextBox3.Text) 'Given initial velocity
-
Dim density As Double = CInt(TextBox4.Text)
-
Dim Height As Double = 0.0
-
Dim time As Double = 0.0
-
Dim Distance As Double = 0.0
-
Dim Vx As Double = 0.0 'Horizontal velocity component
-
Dim Vy As Double = 0.0 'Vertical velocity component
-
Dim rad As Double
-
Dim new_velocity As Double
-
Dim Cd As Double = 0.47 'This is the drag coefficient and we assume that is constant
-
Dim A As Double = Math.PI * 0.05 ^ 2 'This is the cross-sectional area of the ball
-
Dim drag As Double
-
Dim drag_x As Double 'The horizontal drag component
-
Dim drag_y As Double 'The vertical drag component
-
-
Dim ITEMS As ListViewItem
-
-
If angle > 180 Then
-
MsgBox("PLEASE ENTER A SMALLER ANGLE")
-
-
ElseIf angle < 0 Then
-
MsgBox("PLEASE ENTER A POSITIVE ANGLE")
-
-
ElseIf mass < 0 Then
-
MsgBox("PLEASE ENTER A POSITIVE MASS")
-
Else
-
-
-
-
rad = (angle / 180) * Math.PI 'Calculate the angle in rads
-
Vx = initial_velocity * Math.Cos(rad)
-
Vy = initial_velocity * Math.Sin(rad)
-
-
-
Do
-
-
time = time + 0.01
-
-
-
Vy = Find_Verical_Velocity(Vy, mass, drag_y)
-
Vx = Find_Horizontal_Velocity(Vx, mass, drag_x)
-
-
rad = Math.Atan(Vy / Vx) 'Because the angle changes during the flihgt it calculates the angle in different points
-
new_velocity = Math.Sqrt((Vy ^ 2) + (Vx ^ 2))
-
-
-
drag = 0.5 * Cd * density * new_velocity ^ 2 * A
-
-
drag_x = drag * Math.Cos(rad)
-
drag_y = drag * Math.Sin(rad)
-
-
-
angle = (rad * 180) / Math.PI
-
-
Distance = Find_Distance(Vx)
-
-
Height = Find_Height(Vy)
-
-
ITEMS = New ListViewItem(Math.Round(time, 4))
-
ITEMS.SubItems.Add(Math.Round(Distance, 4))
-
ITEMS.SubItems.Add(Math.Round(Height, 4))
-
ITEMS.SubItems.Add(Math.Round(angle, 4))
-
ITEMS.SubItems.Add(Math.Round(new_velocity, 4))
-
ITEMS.SubItems.Add(Math.Round(Vy, 4))
-
ITEMS.SubItems.Add(Math.Round(Vx, 4))
-
ListView1.Items.Add(ITEMS)
-
-
Loop Until (Height < 0)
-
-
End If
-
End Sub
-
End Class
Hallo, in the above program we put as inputs the angle, the initial velocity, the mass and the density of a rocket, and then it calculates the distance, the time the height, the velocity and the initial velocity of the rocket until it comes down to the ground. I would like to import the results of the distance and the height into the excel in order to draw a graph.
Please help me.
Thank you
Ok. The simplest way that I know how to do this is to create an excel file with graph and named ranges for the data cells. Add excel as a reference in your project and use ole automation to open the graph and change the data in the named ranges.
There is a vba tutorial here that should help you get started
Ok. The simplest way that I know how to do this is to create an excel file with graph and named ranges for the data cells. Add excel as a reference in your project and use ole automation to open the graph and change the data in the named ranges.
There is a vba tutorial here that should help you get started
Thank You very much
Thank You very much
You are very welcome. Good luck
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Omar |
last post by:
Hi Developers,
I am trying to access an Excel data file through a VB.Net application.
I have the following code:
=================================== VB.Net Code ===================
Dim...
|
by: Steve |
last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains
custom functions. I believe I need to use COM interop to allow VBA code in
Excel 2002 to access it. I've studied...
|
by: sqlguy |
last post by:
Why do we have to contact MS for a problem that has been with this
compiler from at least the beta of VS 20005. I am so sick and tired of
the 30 - 40 clicks it takes to dismiss VS when there is a...
|
by: Master Programmer |
last post by:
An friend insider told me that VB is to be killled off within 18
months. I guess this makes sence now that C# is here. I believe it and
am actualy surprised they ever even included it in VS 2003 in...
|
by: geiaaa |
last post by:
hello and happy new year...
I just started a project were I need to call dll functions from within excel.
More specifically I have created a custom dll in Visual Basic (visual studio 2005) with the...
|
by: Javier1958 |
last post by:
Hi all
I have a problem running Visual Basic 2005 (.NET) programs in other computers different of that where I have Visual Studio installed.
I know I have to install the .NET framework in the...
|
by: Speilman_54 |
last post by:
Hi,
I'm converting an excel Macro into visual basic 2005 express, as I
don't have a copy of VB 6 and trying to make and executable from it,
I know this version doesn't have the save file as .exe,...
|
by: Amit |
last post by:
Hello group,
I"m new to COM Interop and Add-Ins. Today I was reading an article
that says: "Use Visual Studio Tools for the Microsoft Office System to
create a new Excel Workbook project in...
|
by: chrspta |
last post by:
I am new to Visual basic. I need a program using VB6 that converts txt files to excel file.Description is in the below:
The form should have the Drive list, Dir list, file list and cmdConvert...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |