473,692 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cant fix my Compile error: expected array for VBE excel, need help very new at this??

1 New Member
every time i run this program in VBE i keep getting the message
'Compile Error: expected array' for the two bold lines underneath, please help?



Public Function KnotsToKmPerHr( knots As Double) As Double
Dim Km As Double
KNOTS_TO_KM = 1.852
Km = knots * KNOTS_TO_KM
KnotsToKmPerHr = Km
End Function


Sub CreateFlightPla n()

Dim row As Integer
Dim col As Integer
Dim dblAirSpeed As Double
Dim dblWindSpeed As Double
Dim angle As Double
Dim angle2 As Double
Dim KnotsToKmPerHr As Double
Dim bearing As Double
Dim direction As Double
Dim beta As Double
Dim alpha As Double
col = COL_LEG_BEARING
row = ROW_FIRST_LEG

KnotsToKmPerHr = 1.852

dblAirSpeed = ActiveSheet.Ran ge(CELL_AIRSPEE D) ' in knots
AirSpeed = KnotsToKmPerHr(dblAirSpeed)
dblWindSpeed = ActiveSheet.Cel ls(row, COL_WIND_SPEED)
WindSpeed = KnotsToKmPerHr(dblWindSpeed)
bearing = ActiveSheet.Cel ls(row, col).Value

While ActiveSheet.Cel ls(row, col) <> ""

If bearing >= 0 And bearing < 270 Then
angle = -bearing + 90
ElseIf bearing >= 270 And bearing <= 360 Then
angle = -bearing + 450
End If

direction = ActiveSheet.Cel ls(row, COL_WIND_DIR).V alue

If direction > 0 And direction < 270 Then
angle2 = -direction + 90
ElseIf direction >= 270 And direction < 360 Then
angle2 = -direction + 450
End If

angle2 = angle2 + 90
alpha = angle2 + angle

beta = ArcSin((Sin(alp ha) * WindSpeed) / AirSpeed)

row = row + 1

Wend

End Sub
Sep 17 '08 #1
1 5145
MikeTheBike
639 Recognized Expert Contributor
every time i run this program in VBE i keep getting the message
'Compile Error: expected array' for the two bold lines underneath, please help?



Public Function KnotsToKmPerHr( knots As Double) As Double
Dim Km As Double
KNOTS_TO_KM = 1.852
Km = knots * KNOTS_TO_KM
KnotsToKmPerHr = Km
End Function


Sub CreateFlightPla n()

Dim row As Integer
Dim col As Integer
Dim dblAirSpeed As Double
Dim dblWindSpeed As Double
Dim angle As Double
Dim angle2 As Double
Dim KnotsToKmPerHr As Double
Dim bearing As Double
Dim direction As Double
Dim beta As Double
Dim alpha As Double
col = COL_LEG_BEARING
row = ROW_FIRST_LEG

KnotsToKmPerHr = 1.852

dblAirSpeed = ActiveSheet.Ran ge(CELL_AIRSPEE D) ' in knots
AirSpeed = KnotsToKmPerHr(dblAirSpeed)
dblWindSpeed = ActiveSheet.Cel ls(row, COL_WIND_SPEED)
WindSpeed = KnotsToKmPerHr(dblWindSpeed)
bearing = ActiveSheet.Cel ls(row, col).Value

While ActiveSheet.Cel ls(row, col) <> ""

If bearing >= 0 And bearing < 270 Then
angle = -bearing + 90
ElseIf bearing >= 270 And bearing <= 360 Then
angle = -bearing + 450
End If

direction = ActiveSheet.Cel ls(row, COL_WIND_DIR).V alue

If direction > 0 And direction < 270 Then
angle2 = -direction + 90
ElseIf direction >= 270 And direction < 360 Then
angle2 = -direction + 450
End If

angle2 = angle2 + 90
alpha = angle2 + angle

beta = ArcSin((Sin(alp ha) * WindSpeed) / AirSpeed)

row = row + 1

Wend

End Sub
Hi

I think there are probable two solution to this,

1) Remove the public function and change the lines from this

AirSpeed = KnotsToKmPerHr( dblAirSpeed)
WindSpeed = KnotsToKmPerHr( dblWindSpeed)

to this

AirSpeed = KnotsToKmPerHr* dblAirSpeed
WindSpeed = KnotsToKmPerHr* dblWindSpeed

OR

2) Remove these two lines

Dim KnotsToKmPerHr As Double
KnotsToKmPerHr = 1.852

This is on the basis that AirSpeed and WindSpeed are declared elsewhere ?

Also, all other calculations seem a waste of time because they only have scope inside the Sub and don't seem to be used for any purpose elsewhere (ie written to the spreadsheet)??

Of course I could be missing something, or this is early in developement !!


MTB
Sep 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2318
by: Tiernan | last post by:
Hey everybody. I'm verry new to PHP and MYSQL and have been working on a form that when it is submitted stores the information into a mysql database. The main problem is that i'm trying to finish up my script for almost a week now and I still cant get it right. here is the code <?php include ("ES_includes/appconst.inc.php") ;
7
3050
by: Paul | last post by:
I thought this is more of an IE issue but i've had no joy on that group perhaps somebody here will have a clue. If i click a link to a web page embedded in Excel (97 OR 2000) i get the standard error page displayed by IE (you know, the 'cannot find server or dns error' page). Turning off 'show friendly http error messages' alleviates this. (Unfortunately this is the Windows default setting!) Whats going on?!?!
5
18009
by: Andrew V. Romero | last post by:
At work we have an excel file that contains the list of medications and their corresponding strengths. I would like to save the excel file as a text list and paste this list into a javascript function and have JS put this into an array. Then JS would use this array to create a selection list which displays only the names of the drugs. When the user selections one of the drugs, another selection list will be loaded with the avaiable...
1
4906
by: Amen | last post by:
Hi! I'm new to VB Script but I need some help. I ran a macro in Excel to copy a text file to a sheet. It worked fine I then proceded to copy the macro to a script but wehn I try to run it I get the compilation Error 800A03EE Script: D:\Scrip_tables.vbs Line: 14 Char: 49 Error: Expected ')'
5
3328
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new rightType;
0
3666
by: vinidimple | last post by:
Hi i have a serious problem while i was working in Excel.I want to fetch columns from an excel worksheet and i need to compare it with an sql querry fields,so i tried to open an excle worksheet first.. Unfortunately my code was throwing error like
5
5039
by: wong_powah | last post by:
#include <vector> #include <iostream> using std::cout; using std::vector; enum {DATASIZE = 20}; typedef unsigned char data_t;
0
3001
by: Anish G | last post by:
Hi All, I am getting the below given error while running my application in live server. In my local machine, its working fine. Please help me as it is very urgent for me. Exception from HRESULT: 0x800A03EC Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:...
0
1514
by: ppletkov | last post by:
Hi - I apologize if this is a simple question in advance :-) (hopefully it is so its quickly resolved!) i'm trying to figure out why i keep getting an error (Compile Error : expected function or variable) for my .find method. I have checked the format of this statement and it appears correct...? Dim ItemNumberWLO As String Dim ItemNumberWLN As String While Not WLO.EOF
0
8545
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9090
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8810
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5822
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4562
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2242
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.