Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,578 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,941 people online right now. Registration is fast and FREE... Join Now!




Dynamic Arrays

 
Reply to this topicStart new topic

Dynamic Arrays, Dynamic arrays & how to do the calculations are confusing

dmcollette664
28 Sep, 2008 - 06:46 AM
Post #1

New D.I.C Head
*

Joined: 13 Sep, 2008
Posts: 13

Hi!

I am having a problem grasping how to pull the data out of a dynamic array. The user is to enter the number of temperatures that wish to have me work with, then they enter the numbers. I need to preform a number of different calculations on the data.
1. average of all temps
2. count the number of temps equal to the average
3. count the number of temps above freezing (fahrenheit)
4. count the number of temps below freezing (fahrenheit)
5. display all the numbers user entered

Then display everything in one message box at the end.

I have attached the file.

All help is appreciated!

Thanks!



Option Explicit
dim arrtemp(),numtemp,x,mess,avtemp
numtemp=InputBox("How many temperatures would you like to enter?","Number of Temperatures")
numtemp=CInt(numtemp)
x=numtemp-1
ReDim arrtemp(x)
For Each x In arrtemp
mess=inputbox("Enter a temperature")
Next
For arrtemp=0 To(x+1)

This post has been edited by dmcollette664: 28 Sep, 2008 - 06:50 AM
User is offlineProfile CardPM
+Quote Post

akhileshbc
RE: Dynamic Arrays
28 Sep, 2008 - 07:04 AM
Post #2

D.I.C Head
Group Icon

Joined: 26 Sep, 2008
Posts: 177



Thanked: 3 times
Dream Kudos: 50
My Contributions
For i=0 to x
arraytemp(i)=inputbox("no?","enter it")
next i

x+1 is the total no. of elements in the array.
User is offlineProfile CardPM
+Quote Post

thava
RE: Dynamic Arrays
28 Sep, 2008 - 09:17 PM
Post #3

D.I.C Regular
Group Icon

Joined: 17 Apr, 2007
Posts: 450



Thanked: 18 times
Dream Kudos: 50
My Contributions
i thnk its varried based on the users input
ok
did you try the ubound and lbound methods this will return the upperbound and lowerbound of an array use this for the limit for loop
you can calculate all your things using some stadard for loops and if conditions

still you can't able ro reach your height post briefly here what is your problem we will solve it
User is offlineProfile CardPM
+Quote Post

akhileshbc
RE: Dynamic Arrays
29 Sep, 2008 - 07:46 AM
Post #4

D.I.C Head
Group Icon

Joined: 26 Sep, 2008
Posts: 177



Thanked: 3 times
Dream Kudos: 50
My Contributions
@thava, what is the need of ubound in here? He had redimmed the array!
User is offlineProfile CardPM
+Quote Post

dmcollette664
RE: Dynamic Arrays
11 Oct, 2008 - 04:05 AM
Post #5

New D.I.C Head
*

Joined: 13 Sep, 2008
Posts: 13

QUOTE(akhileshbc @ 28 Sep, 2008 - 08:04 AM) *

For i=0 to x
arraytemp(i)=inputbox("no?","enter it")
next i

x+1 is the total no. of elements in the array.



Thank you akhileshbc! I did have the incorrect information to get the array working correctly. This helped.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:25AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month