im using console. ive written code its for my exam and im not very good at it but ive tried and no matter what i do i cant get the program to stop crashing. it keeps crashing at code 0 and im really frustrated please help me ive attached the code below
Module Module1
Sub Main()
Dim discount As Integer = 0
Dim freetickets As Integer = 0
Dim estimatedcost As Integer = 0
Dim totalstudents As Integer = 0
Dim coachcost As Integer = 550
Dim entryticket As Integer = 30
Dim name(45) As String
Dim paidstatus(45) As Boolean
Dim studentspaid As Integer = 0
Dim totalcost As Integer = 0
Dim collectedcost As Integer = 0
Dim finalcost As Integer = 0
Console.WriteLine("Enter Student Name")
name(45) = Console.ReadLine()
Console.WriteLine("has the student paid? (true/false)")
paidstatus(45) = Console.ReadLine()
If paidstatus(45) = True Then
studentspaid = studentspaid + 1
totalstudents = totalstudents + 1
ElseIf paidstatus(45) = False Then
totalstudents = totalstudents + 1
End If
totalcost = (totalstudents * 30) + (550 / totalstudents)
If totalstudents = 45 Then
If studentspaid = 10 Then
freetickets = freetickets + 1
End If
If studentspaid = 20 Then
freetickets = freetickets + 1
End If
If studentspaid = 30 Then
freetickets = freetickets + 1
End If
If studentspaid = 40 Then
freetickets = freetickets + 1
End If
collectedcost = (studentspaid * 30) + (550 / studentspaid)
discount = (freetickets * 30) - (550 / studentspaid)
finalcost = totalcost - collectedcost - discount
If finalcost > 0 Then
Console.WriteLine("loss of")
Console.WriteLine(-finalcost)
End If
If finalcost = 0 Then
Console.WriteLine("broken even")
End If
If finalcost < 0 Then
Console.WriteLine("profit of")
Console.WriteLine(finalcost)
End If
End If
End Sub
End Module
I want to revert the loop to 1 but only in .cmdTable(i).caption = txtPrefix.Text + Str(i) so the name + the number will revert back to 1 because every time a transact it will get the continues number of the loop
I want that Str(i) revert back to 1 on every time i click OK
For example i set the name of the table = TABLE + the number txtEndTable.Text = 5 it will loop from TABLE 1 to TABLE 5 for the second transaction name of the table = MARK + the number txtEndTable.Text = 5 it will generate MARK 6 to MARK 10. I want to get the MARK 1 to MARK 5 for second transaction
Any idea will do
Public Sub pAddMultipleTables()
Dim i As Integer
Dim x As Long
Dim lcDefaultTop As Integer
Dim lcLastLeft As Integer
Dim lcMax As Integer
Dim lcSpacing As Integer
Dim lcCurrentTable As Integer
Dim lcStart As Integer
lcSpacing = 1200
lcDefaultTop = 1300
lcMax = 5
lcCurrentTable = 1
lcLastLeft = 240
lcStart = 0
x = 0
With frmTableMap
For i = .cmdTable.ubound + 1 To .cmdTable.ubound + txtEndTable.Text
Load .cmdTable(i)
.cmdTable(i).Visible = True
If lcCurrentTable < lcMax Then
If lcCurrentTable = 1 Then
.cmdTable(i).Top = lcDefaultTop
Else
.cmdTable(i).Top = (.cmdTable(i - 1).Top + .cmdTable(i - 1).Height) + 120
End If
.cmdTable(i).Left = lcLastLeft
lcCurrentTable = lcCurrentTable + 1
' Add to database
.cmdTable(i).ZOrder 0
If optSquare.Value = True Then
.cmdTable(i).ButtonShape = 0
Else
.cmdTable(i).ButtonShape = 4
End If
.cmdTable(i).Caption = txtPrefix.Text + Str(i)
bRS.AddNew
bRS!Name = txtPrefix.Text + Str(i)
bRS!buttonorder = .cmdTable(i).Index
bRS!section = .lblSection.Caption
bRS!ForeColor = .cmdTable(i).ForeColor
bRS!FontSize = .cmdTable(i).Font.Size
bRS!Width = .cmdTable(i).Width
bRS!Height = .cmdTable(i).Height
bRS!Top = .cmdTable(i).Top
bRS!Left = .cmdTable(i).Left
bRS!FontBold = .cmdTable(i).Font.Bold
bRS!FontName = .cmdTable(i).Font.Name
bRS!BackColor = .cmdTable(i).BackColor
bRS!Capacity = txtCapacity.Text
bRS!Type = "1"
If optSquare.Value = True Then
bRS!ButtonShape = 0
Else
bRS!ButtonShape = 4
End If
bRS.Update
ElseIf lcCurrentTable = lcMax Then
If i > 1 Then
.cmdTable(i).Top = (.cmdTable(i - 1).Top + .cmdTable(i - 1).Height) + 200
.cmdTable(i).Left = lcLastLeft
End If
lcLastLeft = (lcLastLeft + .cmdTable(i).Width) + 120
lcCurrentTable = 1
.cmdTable(i).ZOrder 0
If optSquare.Value = True Then
.cmdTable(i).ButtonShape = 0
Else
.cmdTable(i).ButtonShape = 4
End If
.cmdTable(i).Caption = txtPrefix.Text + Str(i)
bRS.AddNew
bRS!Name = txtPrefix.Text + Str(i)
bRS!buttonorder = .cmdTable(i).Index
bRS!section = .lblSection.Caption
bRS!ForeColor = .cmdTable(i).ForeColor
bRS!FontSize = .cmdTable(i).Font.Size
bRS!Width = .cmdTable(i).Width
bRS!Height = .cmdTable(i).Height
bRS!Top = .cmdTable(i).Top
bRS!Left = .cmdTable(i).Left
bRS!FontBold = .cmdTable(i).Font.Bold
bRS!FontName = .cmdTable(i).Font.Name
bRS!BackColor = .cmdTable(i).BackColor
bRS!Capacity = txtCapacity.Text
bRS!Type = "1"
If optSquare.Value = True Then
bRS!ButtonShape = 0
Else
bRS!ButtonShape = 4
End If
bRS.Update
End If
Next
End With
End Sub
-Thanks guys
This might not be the most elegant solution but something like this might work.
For i = .cmdTable.lbound + 1 To .cmdTable.ubound + CInt(txtEndTable.Text)
https://msdn.microsoft.com/en-us/library/t9a7w1ac(v=vs.90).aspx
I have designed a calculator through bascome avr and proteus, but some numbers in keypad dont work correctly. just 1 , 4 and 7 work nice. 2 and 3 show 1, 5 and 6 show 4, 8 and 9 show 7! where is the problem?
My bascom code:
$regfile = "M32DEF.DAT"
$crystal = 8000000
Config Kbd = Portd
Config Lcdpin = Pin , Db4 = Pinb.4 , Db5 = Pinb.5 , Db6 = Pinb.6 , Db7 = _ Pinb.7 , Rs = Pinb.2 , E = Pinb.3
Config Lcd = 20 * 2
Dim A As Single
Dim B As Single
Dim S As Byte
Dim Yab As Single
Dim X As Byte
Dim Y As Byte
Star:
A = 0
S = 0
B = 0
Cls
Do
Start1:
X = Getkbd()
If X >= 16 Then Goto Start1
X = Lookup(x , Key)
If X = 47 Or X = 42 Or X = 45 Or X = 13 Or X = 61 Or X = 43 Then Exit Do
If S > 5 Then Goto Start1
A = A * 10
A = A + X
Locate 1 , 1
Lcd A
Waitms 100
Incr S
Loop
Cls
If X = 13 Then Goto Star
Y = X
S = 0
Locate 1 , 1
Lcd A ; Chr(y)
Waitms 100
Do
Start2:
X = Getkbd()
If X >= 16 Then Goto Start2
X = Lookup(X , Key)
If X = 47 Or X = 42 Or X = 45 Or X = 13 Or X = 61 Or X = 43 Then Exit Do
If S > 5 Then Goto Start2
B = B * 10
B = B + X
Locate 1 , 1
Lcd A ; Chr(y) ; B
Waitms 100
Incr S
Loop
If X = 13 Then Goto Star
S = 0
Locate 1 , 1
Lcd A ; Chr(Y) ; B
Waitms 100
Select Case Y
Case 47 : Yab = A / B
Case 42 : Yab = A * B
Case 45 : Yab = A - B
Case 43 : Yab = A + B
End Select
Locate 2 , 1
Lcd " ="
Locate 2 , 2
Lcd Yab
A = Yab
S = 6
B = 0
Goto Start1
End
Key:
Data 7 , 8 , 9 , 47 , 4 , 5 , 6 , 42 , 1 , 2 , 3 , 45 , 13 , 0 , 61 , 43
Try to assemble like this, Use portB for keypad and, 470 ohms resistor ...
See this Image
I have a few hexadecimal values which contain time data. I've tried to figure out the format using different conversions (seconds, minutes, bitshifts and so on) but without success. How do I convert those hex values to hours and minutes?
HH:MM HEX DEC
00:03 = 006A = 106
08:44 = 4185 = 16773
11:00 = 5285 = 21125
12:23 = 5CE5 = 23781
12:29 = 5DA5 = 23973
13:13 = 6325 = 25381
14:04 = 6985 = 27013
15:40 = 7585 = 30085
16:31 = 7BE5 = 31717
18:23 = 89E5 = 35301
18:42 = 8C43 = 35907
18:51 = 8D65 = 36197
19:20 = 9105 = 37125
19:25 = 91A5 = 37285
19:36 = 930B = 37643
23:36 = B105 = 45317
23:39 = B165 = 45413
It would seem that if you shift the values right by 5 bits you get a time value in minutes.
The bottom bits seem to vary. I'm not sure what they mean.
Anyone can explain what these hooks do? Especially WH_MIN and WH_MAX.
http://msdn.microsoft.com/en-us/library/ms644959(VS.85).aspx
WH_MIN = -1
WH_MSGFILTER = -1
WH_JOURNALRECORD = 0
WH_JOURNALPLAYBACK = 1
WH_KEYBOARD = 2
WH_GETMESSAGE = 3
WH_CALLWNDPROC = 4
WH_CBT = 5
WH_SYSMSGFILTER = 6
WH_MOUSE = 7
WH_HARDWARE = 8
WH_DEBUG = 9
WH_SHELL = 10
WH_FOREGROUNDIDLE = 11
WH_CALLWNDPROCRET = 12
WH_KEYBOARD_LL = 13
WH_MOUSE_LL = 14
WH_MAX = 15
MIN and MAX values like that are usually just there so you know the range of valid numbers