Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Steer me in the right direction

Posted on 2000-02-14
8
191 Views
Last Modified: 2010-05-02
I am writing two applications.
One is going to display information in a Gauge like format as on the dashboard of a car but I dont know how to do this.
The art I dont think I need help with but if I use needle gauges I need to make a line rotate a certain number of degrees based on some number input.  I hope this is making sense.

The second thing is that I am writing software to make a timeline simply by me adding events and a Date into a database I want to the app to create a visual time line of the events.

Any help will be appreciated.
-Badman
0
Comment
Question by:badman
8 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2519807
For your first question, use the CCROP Progress bar control (http://www.mvps.org/ccrp/controls/ccrpprogbar6.htm).

For the timeline, see this one: http://support.microsoft.com/support/kb/articles/Q112/6/50.asp?LNG=ENG&SA=ALLKB&FR=0
0
 
LVL 4

Expert Comment

by:nutwiss
ID: 2521924
while you're at it, check out the rest of www.mvps.org :)
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2527495
I wouldnt recommend adding a new custom control to your project just to rotate a line. The calculation is pretty straightforward geometry.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2527540
Why reinvent the wheel when the wheel exists and good?
0
 

Accepted Solution

by:
olly_george earned 110 total points
ID: 2530409
To rotate a point about the origin (x=0, y=0) you can use use...

Public Type tPOINT
    fX As Single
    fY As Single
End Type

Public Sub RotatePoint(fAngle As Single, Point As tPOINT)
    ' Rotates the point about the origine
    Dim TempPoint As tPOINT
    TempPoint = Point
   
    Point.fX = (TempPoint.fX * Cos(fAngle)) + (TempPoint.fY * Sin(fAngle))
    Point.fY = (TempPoint.fY * Cos(fAngle)) - (TempPoint.fX * Sin(fAngle))
   
   
End Sub

so if you're rotating X1 and Y1 about X2 and Y2, use this

Private Sub Timer1_Timer()
    Dim Point As tPOINT
    With Line1
        Point.fX = .X1 - .X2
        Point.fY = .Y2 - .Y1
        RotatePoint 0.1, Point
        .X1 = Point.fX + .X2
        .Y1 = .Y2 - Point.fY
    End With
End Sub

remember angle is in radians


for the timeline, a vb date is stored as an 8 byte number, with the number before the decimal specifying the date and after - the time. If your time line has a start date and an end date, you can cast your event dates to be doubles and work out the fraction along the line


slap a picture box on a form and paste in this code

Private Type tEVENT
    sName As String
    dteWhen As Date
End Type


Private ga_Events() As tEVENT
Private g_dteStart As Date
Private g_dteEnd As Date

Private Sub Form_Load()
    g_dteStart = "1/1990"
    g_dteEnd = "1/1/2000"
    ReDim ga_Events(0 To 9)
    ' 10 events
    ga_Events(0).sName = "Event 1"
    ga_Events(0).dteWhen = "1/1/1990"
    ga_Events(1).sName = "Event 2"
    ga_Events(1).dteWhen = "1/10/1990"
    ga_Events(2).sName = "Event 3"
    ga_Events(2).dteWhen = "1/1/1991"
    ga_Events(3).sName = "Event 4"
    ga_Events(3).dteWhen = "1/1/1992"
    ga_Events(4).sName = "Event 5"
    ga_Events(4).dteWhen = "1/10/1997"
    ga_Events(5).sName = "Event 6"
    ga_Events(5).dteWhen = "1/11/1997"
    ga_Events(6).sName = "Event 7"
    ga_Events(6).dteWhen = "1/10/1998"
    ga_Events(7).sName = "Event 8"
    ga_Events(7).dteWhen = "1/11/1998"
    ga_Events(8).sName = "Event 9"
    ga_Events(8).dteWhen = "1/10/1999"
    ga_Events(9).sName = "Event 10"
    ga_Events(9).dteWhen = "1/12/1999"
   
    Dim n  As Integer
    Dim fSpan As Single
    Dim dTimeSpan As Double
   
    fSpan = Picture1.Width
    dTimeSpan = CDbl(g_dteEnd) - CDbl(g_dteStart)
    Dim fPosition As Single
   
    For n = 0 To 9
        fPosition = CSng(fSpan * ((CDbl(ga_Events(n).dteWhen) - CDbl(g_dteStart)) / dTimeSpan))
        Picture1.Line (fPosition, 0)-(fPosition, Picture1.Height)
    Next n
   
End Sub



0
 

Expert Comment

by:olly_george
ID: 2530448
oh yeah, I forgot to say, set the autoredraw property on the picturebox to be true
0
 

Author Comment

by:badman
ID: 2534117
I want to give Points to both Olly-George and emoreau...both answers were excellent.
How do I do it?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2534801
You have to create new questions that looks like "for expert_Id only"
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question