?
Solved

Using a picture box to draw a 70mm length of a 8Ghz sine wave

Posted on 2003-03-24
4
Medium Priority
?
370 Views
Last Modified: 2010-05-01
I have an 8Ghz sine wave and I need to draw a 70mm lentgh of this in a picture box that has axis labelled 0 - 70 mm (x-axis) and -1.5 - +1.5 (y-axis). What would be the code for such a picture box? Can anyone help....please?
0
Comment
Question by:nickclaridge
[X]
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
  • 2
4 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 8198298
I'm not sure if I'm on track with this, but how about:

Private Sub Command2_Click()
  Dim PI As Double
  Dim iWidth As Integer
  Dim iHeight As Integer
  Dim iPixel As Integer
  Dim dblSine As Double
 
  PI = 4 * Atn(1)'3.14159265358979
 
  iWidth = Picture1.ScaleWidth
  iHeight = Picture1.ScaleHeight
 
  Picture1.Cls
  Picture1.Line (0, iHeight / 2)-(iWidth, iHeight / 2), vbBlue
  For iPixel = 0 To iWidth
    dblSine = Sin(iPixel * (360 / iWidth) * PI / 180)
    Picture1.PSet (iPixel, iHeight / 2 - dblSine * iHeight / 2), vbRed
  Next iPixel
End Sub

The 70mm and -1.5/+1.5 numbers will merely be labels since all sine waves are the same.
0
 

Author Comment

by:nickclaridge
ID: 8198480
Hi. This helps for the drawing of the sine wave but how would I draw an 8Ghz wave in this box???
0
 
LVL 6

Accepted Solution

by:
GPrentice00 earned 80 total points
ID: 8199731
See your other message for comments on this, but I've added a bit of code to the above code to demonstrate multiwaves in a box if thats what your after.

Its not a well-written code, and I haven't factored in the actual real wavelength scale changes, but its an easy add-in modification to add to this example provided by rspahitz that can show you a demo, if thats what you want or if its not the idea.

' Add a hscroll bar and a lable1 to the example form.

' Scalefactor will determine how many sine waves to draw in the box...
' WindowwaveFixed10 says how many waves to fit in the window for 10Ghz
' GHZscalefactor is used to get finer intervals on the scrollbar.
Public ScaleFactor As Single
 Const WindowWaveFixed10 As Integer = 5
 Const GHZscalefactor As Integer = 100


Private Sub Form_Load()
' disable the scroll bar to program changes into it
' scale from 8.00 ghz to 12.00ghz
' set at 10 ghz
   HScroll1.Enabled = False
   HScroll1.Min = 8 * GHZscalefactor
   HScroll1.Max = 12 * GHZscalefactor
   HScroll1.Value = 10 * GHZscalefactor
   HScroll1.LargeChange = GHZscalefactor
   HScroll1.Enabled = True
   
End Sub

Private Sub HScroll1_Change()
   ScaleFactor = 10 * (WindowWaveFixed10) * GHZscalefactor / (HScroll1.Value)
   Label1.Caption = CStr(Val(HScroll1.Value / GHZscalefactor)) & " GHz"
   Command2_Click
End Sub

'
' modify the dblsine equation to be...
' ...Sin(iPixel * ScaleFactor * (360...
0
 

Author Comment

by:nickclaridge
ID: 8199833
This is great thanks. It works!!!! I think I should be able to modify it for my needs. If not I'll post another question.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

762 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