Outputting sine waves on xy plots — stuck on certain parts - vb.net

Please help I want to know exactly what is going on in this code for a questions and answers exam tomorrow.
I don't need any help with writing the code because that would be cheating. I made a tiny few mistakes please forgive me I rectified most of theses I don't need help with the mistakes just with the comments and understanding mostly how it works.
Private Sub Command1_Click()
MSComm1.Output = "83" + Chr$(13)
End Sub
Private Sub Form_Load()
MSC1.PortOpen = True
Average_val = 0
minimum_val = 255
maximum_val = 0
Screenshotofsinewave.Left = 0
Screenshotofsinewave.Channel(0).TraceVisible = True
Screenshotofsinewave.Channel(0).MarkersVisible = True
sumofall_val = 0
Screenshotofsinewave.TitleVisible = False
Screenshotofsinewave.Top = 0
Screenshotofrectifiedsinewave.TitleVisible = False
Screenshotofrectifiedsinewave.Channel(0).TraceVisible = True
Screenshotofrectifiedsinewave.Channel(0).MarkersVisible = True
Screenshotofrectifiedsinewave.Top = 0
Screenshotofrectifiedsinewave.Left = 0
Screenshotoflevelshiftedsinewave.Top = 0
Screenshotoflevelshiftedsinewave.Left = 0
Screenshotoflevelshiftedsinewave.TitleVisible = False
Screenshotoflevelshiftedsinewave.Channel(0).TraceVisible = True
Screenshotoflevelshiftedsinewave.Channel(0).MarkersVisible = True
End Sub
Private Sub MSC1_OnComm()
Dim number_val
Dim number1_val
Dim Average_val
Dim com1_val
p = 0
q = 0
r = 0
s = 0
t = 0
Dim Xarr(50) As Single
Dim Yarr(50) As Single
Dim number2_val
Dim number3_val
Dim Snapshotofsinewave
Dim string1_out As String
Dim string1_in As String
Dim counter As Single
Dim sample_rate As Integer
Select Case MSC1.CommEvent
Case comEvReceive
minimum_val = 255
string1_in = MSC1.Input
Screenshotofsinewave.Channel(0).Clear
Screenshotofrectifiedsinewave.Channel(0).Clear
Screenshotoflevelshiftedsinewave.Channel(0).Clear
counter = 0
comm_count = comm_count + 1
For sample_rate = 1 To 150 Step 3
string1_out = Mid(string1_in, sample_rate, 3)
counter = counter + 1
number_val = Val(string1_out)
Xarr(counter) = counter
Yarr(counter) = number_val
Screenshotofsinewave.Channel(0).AddXY counter, number_val
If number_val > maximum_val Then
maximum_val = number_val
MaxVoltage.Value = maximum_val
End If
If number_val < minimum_val Then
minimum_val = number_val
MinVoltage.Value = number_val
End If
sumofall_val = number_val + sumofall_val
Average_value = sumofall_val / 50
AverageVoltage.Value = Average_value
Next sample_rate
counter = 0
sumofall_val = 0
For sample_rate = 1 To 150 Step 3
string1_out = Mid(string1_in, sample_rate, 3)
counter = counter + 1
number_val = Val(string1_out)
number_val = number1_val - Average_value
number_val = numer_val
If num_val1 < 0 Then
number_val = number_val * -1
End If
Xarr(counter) = counter
Yarr(counter) = number1_val
Screenshotofrectifiedsinewave.Channel(0).AddXY counter, number1_val
Next sample_rate
counter = 0
For sample_rate = 1 To 150 Step 3
string1_out = Mid(string1_in, sample_rate, 3)
Count = Count + 1
number_val = Val(string1_out)
number2_val = number_val + Average_value
Xarr(Count) = counter
Yarr(Count) = number2_val
LevelShifted.Channel(0).AddXY Count, number_val2
sumofall_val = number_val + sumofall_val
Next sample_rate
counter = com1_val
Snapshotofsinewave.Value = com1_val
End Select
End Sub
Private Sub Frame4_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
Private Sub Uploaddata_Click()
If GXSwitch1.SwitchOn = True Then
led1.LampOn = True
p = 8
Else
led1.LampOn = False
p = 0
End If
If GXSwitch2.SwitchOn = True Then
led2.LampOn = True
q = 4
Else
led2.LampOn = False
q = 0
End If
If GXSwitch3.SwitchOn = True Then
led3.LampOn = True
r = 4
Else
led3.LampOn = False
r = 0
End If
If GXSwitch4.SwitchOn = True Then
led4.LampOn = True
s = 8
Else
led4.LampOn = False
s = 0
End If
t = p + q + r + s
If t = 0 Then
MSC1.Output = "0" + Chr$(13)
End If
If t = 1 Then
MSC1.Output = "1" + Chr$(13)
End If
If t = 2 Then
MSC1.Output = "2" + Chr$(13)
End If
If t = 3 Then
MSC1.Output = "3" + Chr$(13)
End If
If t = 4 Then
MSC1.Output = "4" + Chr$(13)
End If
If t = 5 Then
MSC1.Output = "5" + Chr$(13)
End If
If t = 6 Then
MSC1.Output = "6" + Chr$(13)
End If
If t = 7 Then
MSC1.Output = "7" + Chr$(13)
End If
If t = 8 Then
MSC1.Output = "8" + Chr$(13)
End If
If t = 9 Then
MSC1.Output = "9" + Chr$(13)
End If
If t = 10 Then
MSC1.Output = "10" + Chr$(13)
End If
If t = 11 Then
MSC1.Output = "11" + Chr$(13)
End If
If t = 12 Then
MSC1.Output = "12" + Chr$(13)
End If
If t = 13 Then
MSC1.Output = "13" + Chr$(13)
End If
If t = 14 Then
MSC1.Output = "14" + Chr$(13)
End If
If t = 15 Then
MSC1.Output = "15" + Chr$(13)
End If
End Sub

Depends on several factors...
Dim average_val, x As Decimal ' decimal
Dim average_val = 3.2D ' decimal if Option Infer On
Dim average_val = 3.2D ' object with boxed decimal if Option Infer Off
Dim average_val ' Object if Option Strict Off, otherwise an error

Related

algorithm for charge automatic matrix

I need algorithm to charge a matrix of 2^k columns and 2^k rows with a sign value of -1 or +1. The first k+1 columns will charge it but the rest (all combinations of k values) not.
I need to multiply all possibilities of k exp :
I have k = 3
I need to multiply 1*2 and 1*3 and 2*3 and 1*2*3.
This is a simple example, but I need the general solution.
This method use for calculating 2^k factorial design.
I tried the following code with visual basic but it did not work 100% (only the first (k+1) columns of the matrix are correct)
Private Sub Command1_Click()
MSFlexGrid1.Cols = Text1.Text + 1
MSFlexGrid1.Rows = 3
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = 1
MSFlexGrid1.Text = "Min"
MSFlexGrid1.Row = 2
MSFlexGrid1.Text = "Max"
For i = 1 To Text1.Text
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = i
MSFlexGrid1.Text = "F" & Str(i)
Next i
End Sub
Function FactFunct(ByVal M As Integer) As Integer
Dim l As Integer
l = 0
For j = M - 1 To 1 Step -1
l = l + j
Next j
FactFunct = l
End Function
Private Sub Command2_Click()
Dim t As Integer
GR2.Visible = True
GR2.Cols = 2 ^ Val(Text1.Text) + 2
GR2.Rows = 2 ^ Val(Text1.Text) + 3
t = 1
GR2.Col = 1
'-------------------------- Incrementer les colonnes
For i = 1 To Val(Text1.Text) + 1
GR2.Row = 1
'-------------------------- declanchement de la routine
If i > 2 Then
t = t * 2
End If
c = -1
j = 1
l = 2 ^ Val(Text1.Text)
'-------------------------- Incrementer les lignes
Do While j <= l
'-------------------------- chargement de la colonne 1
If GR2.Col = 1 Then
GR2.Text = 1
GR2.Row = GR2.Row + 1
j = j + 1
Else
b = 1
'-------------------------- Incrementer les colonnes
Do While b <= t
GR2.Text = 1 * c
GR2.Row = GR2.Row + 1
b = b + 1
j = j + 1
Loop
c = c * -1
End If
Loop
GR2.Col = GR2.Col + 1
Next i
'-----------------------------produit des colonnes
GR2.Col = Val(Text1.Text) + 1
Dim n, Puissance, PositionText, Nbrboucle, NbrValPro, ValColFix, PosCol As Integer
GridRout.Cols = Val(Text1.Text) - 1
Dim JJ As Integer
JJ = 0
For p = Val(Text1.Text) To 2 Step -1
GridRout.Col = JJ
GridRout.Text = FactFunct(p)
JJ = JJ + 1
Next p
For nbrrow = 1 To 2 ^ Val(Text1.Text)
routine = 2
charg = Val(Text1.Text) + 2
For i = 1 To 2
For j = 2 To Val(Text1.Text) + 1
res = 1
k = j
Do While i < routine
GR2.Row = nbrrow
GR2.Col = k
res = Val(res) * Val(GR2.Text)
k = k + 1
i = i + 1
If k = Val(Text1.Text) + 1 Then
k = j + 1
End If
Loop
For M = j + 1 To Val(Text1.Text) + 1
GR2.Row = nbrrow
GR2.Col = M
res2 = Val(res) * Val(GR2.Text)
GR2.Col = charg
GR2.Text = Val(res2)
charg = charg + 1
Next M
Next j
routine = routine + 1
Next i
Next nbrrow
End Sub
Private Sub Form_Load()
'GR2.Visible = False
'GridRout.Visible = False
End Sub
Private Sub MSFlexGrid1_DblClick()
MSFlexGrid1.Text = InputBox("give a number")
End Sub
Private Sub MSFlexGrid2_Click()
End Sub

Repeating msgbox

I've created 3 combobox as below which are to generate results from a listbox. I would like to generate an error box if any of the 3 comboboxes are left empty. However, the code I wrote generates multiple error msg boxes. How do I fix this so msgbox only appears once?
Private Sub Generateresults_Click()
Dim x As Integer
Dim i As Integer
Dim j As Integer
Dim p As Integer
p = Sheets("Training1A").UsedRange.Rows.Count
Sheets("Results").Range("A2:P" & p).ClearContents
x = 2
For i = 0 To Me.Listtest.ListCount - 1
If Me.Searchoption = "AND" Then
If Me.Listtest.Column(1, i) = Search1 And Me.Listtest.Column(2, i) = Search2 Then
For j = 0 To 9
Sheets("results").Cells(x, j + 1) = Me.Listtest.Column(j, i)
Next j
x = x + 1
Else
x = x
End If
ElseIf Me.Searchoption = "OR" Then
If Me.Listtest.Column(1, i) = Search1 Or Me.Listtest.Column(2, i) = Search2 Then
For j = 0 To 9
Sheets("results").Cells(x, j + 1) = Me.Listtest.Column(j, i)
Next j
x = x + 1
Else
x = x
End If
ElseIf Me.Searchoption = "ALL" Then
For j = 0 To 9
Sheets("results").Cells(x, j + 1) = Me.Listtest.Column(j, i)
Next j
x = x + 1
Else
x = x
**If Searchoption = "" Or Search1 = "" Or Search2 = "" Then
MsgBox "Select an option"
End If**
End If
Next i
End Sub
If you want to bail out after dispaying the first MsgBox, put Exit Sub under it.
If Searchoption = "" Or Search1 = "" Or Search2 = "" Then
MsgBox "Select an option"
Exit Sub
End If
Otherwise, the MsgBox call being inside the For...Next loop body, it will be repeated for every iteration that satisfies the conditions.
If you need to run more code between Next and End Sub regardless of whether the MsgBox was shown or not, then you can also Exit For, to exit the loop but remain inside the procedure:
If Searchoption = "" Or Search1 = "" Or Search2 = "" Then
MsgBox "Select an option"
Exit For
End If

VBA macro for hiding rows based on cell value

I am working on a sheet that has sections which hides/shows a number of rows based on a cell value (between 1-10). At the moment, I have a handful of nested if statements. This has made my workbook painfully slow. Is there a way to shrink this code? Thanks.
If Range("B87").Value = 10 Then
Rows("88:98").EntireRow.Hidden = False
Else
If Range("B87").Value = 9 Then
Rows("98").EntireRow.Hidden = True
Rows("88:97").EntireRow.Hidden = False
Else
If Range("B87").Value = 8 Then
Rows("97:98").EntireRow.Hidden = True
Rows("88:96").EntireRow.Hidden = False
Else
If Range("B87").Value = 7 Then
Rows("96:98").EntireRow.Hidden = True
Rows("88:95").EntireRow.Hidden = False
Else
If Range("B87").Value = 6 Then
Rows("95:98").EntireRow.Hidden = True
Rows("88:94").EntireRow.Hidden = False
Else
If Range("B87").Value = 5 Then
Rows("94:98").EntireRow.Hidden = True
Rows("88:93").EntireRow.Hidden = False
Else
If Range("B87").Value = 4 Then
Rows("93:98").EntireRow.Hidden = True
Rows("88:92").EntireRow.Hidden = False
Else
If Range("B87").Value = 3 Then
Rows("92:98").EntireRow.Hidden = True
Rows("88:91").EntireRow.Hidden = False
Else
If Range("B87").Value = 2 Then
Rows("91:98").EntireRow.Hidden = True
Rows("88:90").EntireRow.Hidden = False
Else
If Range("B87").Value = 1 Then
Rows("90:98").EntireRow.Hidden = True
Rows("88:89").EntireRow.Hidden = False
Else
If Range("B87").Value = 0 Then
Rows("88:98").EntireRow.Hidden = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
You have a whole lot of basically the same code. I took a look and tried to make it more arithmetical, which shortens the code. See if this works:
Sub t()
Dim myVal As String
Dim mainRow As Long, tweakRow As Long
Dim hideRange As Range, showRange As Range
Dim row1 As Long, row2 As Long
mainRow = 98
myVal = Range("B87").Value
If myVal = 10 Then
Rows(mainRow - 10 & ":" & mainRow - 10 + myVal).EntireRow.Hidden = False
ElseIf myVal >= 1 And myVal <= 9 Then
tweakRow = mainRow - 10
row1 = (mainRow - (9 - myVal))
row2 = (mainRow - (10 - myVal))
Set hideRange = Rows(row1 & ":" & mainRow).EntireRow
Set showRange = Rows(tweakRow & ":" & row2).EntireRow
Debug.Print "For a value of " & myVal & ", we will hide range: " & hideRange.Address & ", and show range: " & showRange.Address
hideRange.Hidden = True
showRange.Hidden = False
ElseIf myVal = 0 Then
Rows(mainRow - 10 & ":" & mainRow).EntireRow.Hidden = True
End If
End Sub
I might try a case statement.
Oh, or even use the ElseIf option which would reduce the amount of EndIf statements at the very least.
I think the case code looks something like this:
Select Range("B87").value
Case "1"
Case "2"
...
End Select
You don't need to use EntireRow when using Rows or 'EntireColumnwhen usingColumns`.
Rows("88:98").Hidden = True
If Range("B87").Value > 0 Then
Rows(88).Resize(1 + Range("B87").Value).Hidden = False
End If

Table editing with excel vba causing crashing and cell lockup

I have made a userform that allows the user to select a table and add rows to it and fill those rows with various information, all from the userform. I have run into a few problems with this.
First after adding or during adding the items (after hitting submit) excel would crash. It occurs randomly and is hard to reproduce.
Second after running the macro there is a good chance that all the cells in the workbook and every other object except the userform button will stop working, meaning you can't edit interact or even select anything. Then when I close the workbook excel crashes after saving. This is my major offender and I think causes the other problem.
What causes this freezing and why does it occur? How do I fix it? I have looked around and haven't found anything circumstantial. One post said that I should try editing the table with no formatting on it and I did that and it didn't work.
I can provide the excel workbook at a request basis via pm.
The code:
On Activate -
Public Sub UserForm_Activate()
Set cBook = ThisWorkbook
Set dsheet = cBook.Sheets("DATA")
End Sub
Help Checkbox -
Private Sub cbHelp_Click()
If Me.cbHelp.Value = True Then
Me.lbHelp.Visible = True
Else
Me.lbHelp.Visible = False
End If
End Sub
Brand combobox -
Public Sub cmbBrand_Change()
brandTableName = cmbBrand.Value
brandTableName = CleanBrandTableName(brandTableName)
'if brand_edit is not = to a table name then error is thrown
On Error Resume Next
If Err = 380 Then
Exit Sub
Else
cmbItemID.RowSource = brandTableName
End If
On Error GoTo 0
'Set cmbItemID's text to nothing after changing to a new brand
cmbItemID.Text = ""
End Sub
CleanBrandTableName(brandTableName) function -
Option Explicit
Public Function CleanBrandTableName(ByVal brandTableName As String) As String
Dim s As Integer
Dim cleanResult As String
For s = 1 To Len(brandTableName)
Select Case Asc(Mid(brandTableName, s, 1))
Case 32, 48 To 57, 65 To 90, 97 To 122:
cleanResult = cleanResult & Mid(brandTableName, s, 1)
Case 95
cleanResult = cleanResult & " "
Case 38
cleanResult = cleanResult & "and"
End Select
Next s
CleanBrandTableName = Replace(WorksheetFunction.Trim(cleanResult), " ", "_")
End Function
Public Function CleanSpecHyperlink(ByVal specLink As String) As String
Dim cleanLink As Variant
cleanLink = specLink
cleanLink = Replace(cleanLink, "=HYPERLINK(", "")
cleanLink = Replace(cleanLink, ")", "")
cleanLink = Replace(cleanLink, ",", "")
cleanLink = Replace(cleanLink, """", "")
cleanLink = Replace(cleanLink, "Specs", "")
CleanSpecHyperlink = cleanLink
End Function
Browse button -
Public Sub cbBrowse_Click()
Dim rPos As Long
Dim lPos As Long
Dim dPos As Long
specLinkFileName = bFile
rPos = InStrRev(specLinkFileName, "\PDFS\")
lPos = Len(specLinkFileName)
dPos = lPos - rPos
specLinkFileName = Right(specLinkFileName, dPos)
Me.tbSpecLink.Text = specLinkFileName
End Sub
bFile function -
Option Explicit
Public Function bFile() As String
bFile = Application.GetOpenFilename(Title:="Please choose a file to open")
If bFile = "" Then
MsgBox "No file selected.", vbExclamation, "Sorry!"
Exit Function
End If
End Function
Preview button -
Private Sub cbSpecs_Click()
If specLinkFileName = "" Then Exit Sub
cBook.FollowHyperlink (specLinkFileName)
End Sub
Add Item button -
Private Sub cbAddItem_Click()
Dim brand As String
Dim description As String
Dim listPrice As Currency
Dim cost As Currency
Dim Notes As String
Dim other As Variant
itemID = Me.tbNewItem.Text
brand = Me.tbBrandName.Text
description = Me.tbDescription.Text
specLink = Replace(specLinkFileName, specLinkFileName, "=HYPERLINK(""" & specLinkFileName & """,""Specs"")")
If Me.tbListPrice.Text = "" Then
listPrice = 0
Else
listPrice = Me.tbListPrice.Text
End If
If Me.tbCost.Text = "" Then
cost = 0
Else
cost = Me.tbCost.Text
End If
Notes = Me.tbNotes.Text
other = Me.tbOther.Text
If Me.lbItemList.listCount = 0 Then
x = 0
End If
With Me.lbItemList
Me.lbItemList.ColumnCount = 8
.AddItem
.List(x, 0) = itemID
.List(x, 1) = brand
.List(x, 2) = description
.List(x, 3) = specLink
.List(x, 4) = listPrice
.List(x, 5) = cost
.List(x, 6) = Notes
.List(x, 7) = other
x = x + 1
End With
End Sub
Submit button -
Private Sub cbSubmit_Click()
Dim n As Long
Dim v As Long
Dim vTable() As Variant
Dim r As Long
Dim o As Long
Dim c As Long
Dim w As Variant
Set brandTable = dsheet.ListObjects(brandTableName)
o = 1
listAmount = lbItemList.listCount
v = brandTable.ListRows.Count
w = 0
For c = 1 To listAmount
If brandTable.ListRows(v).Range(, 1).Value <> "" Then
brandTable.ListRows.Add alwaysinsert:=True
brandTable.ListRows.Add alwaysinsert:=True
Else
brandTable.ListRows.Add alwaysinsert:=True
End If
Next
ReDim vTable(1000, 1 To 10)
For n = 0 To listAmount - 1
vTable(n + 1, 1) = lbItemList.List(n, 0)
vTable(n + 1, 2) = lbItemList.List(n, 1)
vTable(n + 1, 3) = lbItemList.List(n, 2)
vTable(n + 1, 5) = lbItemList.List(n, 4)
vTable(n + 1, 6) = lbItemList.List(n, 5)
vTable(n + 1, 7) = lbItemList.List(n, 6)
vTable(n + 1, 8) = lbItemList.List(n, 7)
If lbItemList.List(n, 3) = "" Then
ElseIf lbItemList.List(n, 3) <> "" Then
vTable(n + 1, 4) = lbItemList.List(n, 3)
End If
If n = 0 And brandTable.DataBodyRange(1, 1) <> "" Then
For r = 1 To brandTable.ListRows.Count
If brandTable.DataBodyRange(r, 1) <> "" Then
o = r + 1
' brandTable.ListRows.Add alwaysinsert:=True
End If
Next
End If
brandTable.ListColumns(1).DataBodyRange(n + o).Value = vTable(n + 1, 1)
brandTable.ListColumns(2).DataBodyRange(n + o).Value = vTable(n + 1, 2)
brandTable.ListColumns(3).DataBodyRange(n + o).Value = vTable(n + 1, 3)
brandTable.ListColumns(4).DataBodyRange(n + o).Value = vTable(n + 1, 4)
brandTable.ListColumns(5).DataBodyRange(n + o).Value = vTable(n + 1, 5)
brandTable.ListColumns(6).DataBodyRange(n + o).Value = vTable(n + 1, 6)
brandTable.ListColumns(7).DataBodyRange(n + o).Value = vTable(n + 1, 7)
brandTable.ListColumns(8).DataBodyRange(n + o).Value = vTable(n + 1, 8)
Next
brandTable.DataBodyRange.Select
Selection.Font.Bold = True
Selection.WrapText = True
brandTable.ListColumns(5).DataBodyRange.Select
Selection.NumberFormat = "$#,##0.00"
brandTable.ListColumns(6).DataBodyRange.Select
Selection.NumberFormat = "$#,##0.00"
Unload Me
End Sub
Remove Items button -
Private Sub cbRemoveItems_Click()
Dim intCount As Long
For intCount = lbItemList.listCount - 1 To 0 Step -1
If lbItemList.Selected(intCount) Then
lbItemList.RemoveItem (intCount)
x = x - 1
End If
Next intCount
End Sub
There is other code that does things for the other tabs but they don't interact with this tabs code.

Using a loop in Excel/VBS to populate a form

Please can somebody help me with the correct DIM statements and syntax to simplify the following into a DO UNTIL loop?:
Sub DesRisk_Loader()
Dim Qn(7) As String
Dim Ys(7) As String
Dim No(7) As String
Dim Wk(7) As Integer
Application.ScreenUpdating = False
n = 1
x = 1
Do
Application.Goto Reference:="DesHome"
ActiveCell.Offset(x, 0).Select
Qn(n) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
Ys(n) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
No(n) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
Wk(n) = ActiveCell.Value
x = x + 2
n = n + 1
Loop Until n = 8
''Q.1
If Qn(1) <> "" Then
DesForm.DesFrame1.Visible = True
DesForm.Dq1.Caption = Qn(1)
FH = 0
If Ys(1) = "P" Then
DesForm.D1y.Value = True
Else
DesForm.D1y.Value = False
End If
If No(1) = "O" Then
DesForm.D1n.Value = True
Else
DesForm.D1n.Value = False
End If
DesForm.DesDly1.Value = Wk(1)
Else:
Exit Sub
End If
''Q.2
If Qn(2) <> "" Then
DesForm.DesFrame2.Visible = True
DesForm.Dq2.Caption = Qn(2)
FH = 1
If Ys(2) = "P" Then
DesForm.D2y.Value = True
Else
DesForm.D2y.Value = False
End If
If No(2) = "O" Then
DesForm.D2n.Value = True
Else
DesForm.D2n.Value = False
End If
DesForm.DesDly2.Value = Wk(2)
Else: GoTo Jump1
End If
''Q.3
If Qn(3) <> "" Then
DesForm.DesFrame3.Visible = True
DesForm.Dq3.Caption = Qn(3)
FH = 2
If Ys(3) = "P" Then
DesForm.D3y.Value = True
Else
DesForm.D3y.Value = False
End If
If No(3) = "O" Then
DesForm.D3n.Value = True
Else
DesForm.D3n.Value = False
End If
DesForm.DesDly3.Value = Wk(3)
Else: GoTo Jump1
End If
ditto till..
''Q.7
If Qn(7) <> "" Then
DesForm.DesFrame7.Visible = True
DesForm.Dq7.Caption = Qn(7)
FH = 6
If Ys(7) = "P" Then
DesForm.D7y.Value = True
Else
DesForm.D7y.Value = False
End If
If No(7) = "O" Then
DesForm.D7n.Value = True
Else
DesForm.D7n.Value = False
End If
DesForm.DesDly7.Value = Wk(7)
Else: GoTo Jump1
End If
Jump1:
DesForm.Height = 140 + (FH * 75)
DesForm.DesOK.Top = 85 + (FH * 75)
DesForm.DesCancel.Top = 85 + (FH * 75)
Load DesForm
DesForm.Show
End Sub
Thanks
Scott
At the top of your code (First Line in the entire module), type the following OPTION EXPLICIT
That will help identify all undeclared variables.