X Tutup
Skip to content

Commit fc9450e

Browse files
committed
sVB 3.5.7.5
1 parent 6dc1eb6 commit fc9450e

File tree

28 files changed

+612
-539
lines changed

28 files changed

+612
-539
lines changed

DiagramHelper/DiagramPanel.xaml.vb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,59 +293,71 @@ Public Class DiagramPanel
293293
Case Key.F7
294294
Commands.ChangeBrush(Diagram, Control.ForegroundProperty)
295295
ApplyLastChangeToSelected()
296+
e.Handled = True
296297

297298
Case Key.F11
298299
Commands.IncreaseRotationAngle(Diagram, -45)
299300
ApplyLastChangeToSelected()
301+
e.Handled = True
300302

301303
Case Key.F12
302304
Commands.IncreaseRotationAngle(Diagram, 45)
303305
ApplyLastChangeToSelected()
306+
e.Handled = True
307+
304308
Case Key.K
305309
If Keyboard.Modifiers = ModifierKeys.Control Then
306310
Commands.Skew(Diagram)
307311
ApplyLastChangeToSelected()
308312
End If
313+
e.Handled = True
309314

310315
Case Key.F
311316
If Keyboard.Modifiers = ModifierKeys.Control Then
312317
Commands.ChangeFont(Diagram)
313318
ApplyLastChangeToSelected()
314319
End If
320+
e.Handled = True
315321

316322
Case Key.Oem4
317323
If Keyboard.Modifiers = ModifierKeys.Control Then
318324
Commands.IncreaseFontSize(Diagram, -1)
319325
ApplyLastChangeToSelected()
326+
e.Handled = True
320327
End If
321328

322329
Case Key.Oem6
323330
If Keyboard.Modifiers = ModifierKeys.Control Then
324331
Commands.IncreaseFontSize(Diagram, +1)
325332
ApplyLastChangeToSelected()
333+
e.Handled = True
326334
End If
327335

328336
Case Key.B
329337
If Keyboard.Modifiers = ModifierKeys.Control Then
330338
MenuItem_SubmenuOpened(Nothing, Nothing)
331339
BoldMenuItem.IsChecked = Not BoldMenuItem.IsChecked
340+
e.Handled = True
332341
End If
333342

334343
Case Key.I
335344
If Keyboard.Modifiers = ModifierKeys.Control Then
336345
MenuItem_SubmenuOpened(Nothing, Nothing)
337346
ItalicMenuItem.IsChecked = Not ItalicMenuItem.IsChecked
347+
e.Handled = True
338348
End If
339349

340350
Case Key.U
341351
If Keyboard.Modifiers = ModifierKeys.Control Then
342352
MenuItem_SubmenuOpened(Nothing, Nothing)
343353
UnderlineMenuItem.IsChecked = Not UnderlineMenuItem.IsChecked
354+
e.Handled = True
344355
End If
345356

346357
Case Key.G
347358
If Keyboard.Modifiers = ModifierKeys.Control Then
348359
GroupMenuItem.IsChecked = Not GroupMenuItem.IsChecked
360+
e.Handled = True
349361
End If
350362

351363
Case Key.Enter
@@ -354,6 +366,7 @@ Public Class DiagramPanel
354366

355367
Case Key.Delete
356368
Dsn.RemoveSelectedItems()
369+
e.Handled = True
357370

358371
Case Key.Tab
359372
If Keyboard.Modifiers = ModifierKeys.Shift Then

LangServices/CompilerService.vb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,11 @@ Namespace Microsoft.SmallVisualBasic.LanguageService
446446
If token.Type = TokenType.LineContinuity Then Continue For
447447
If token.Type = TokenType.Colon Then Continue For
448448

449-
If token.Type = TokenType.Question Then
449+
If token.Type = TokenType.DateLiteral Then
450+
If token.Text.Contains("\") Then
451+
textEdit.Replace(line.Start + token.Column, token.EndColumn-token.Column, token.Text.Replace("\", "/"))
452+
End If
453+
ElseIf token.Type = TokenType.Question Then
450454
If i = 0 Then
451455
If n = 1 Then
452456
textEdit.Replace(line.Start + token.Column, 1, "TW.WriteLine("""")")
@@ -504,7 +508,7 @@ Namespace Microsoft.SmallVisualBasic.LanguageService
504508
ElseIf tokens(i - 1).ParseType = ParseType.Operator OrElse
505509
tokens(i - 1).Type = TokenType.Question OrElse
506510
tokens(i - 1).Type = TokenType.To Then
507-
textEdit.Replace(line.Start + token.Column, 1, "TW.Read()")
511+
textEdit.Replace(line.Start + token.Column, 1, "TW.ReadText()")
508512
End If
509513

510514
ElseIf token.Type = TokenType.HashQuestion Then

SBCompiler/SBCompiler/Parser.vb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,9 @@ Namespace Microsoft.SmallVisualBasic
14651465
tokenEnum.MoveNext()
14661466
If Not tokenEnum.IsEndOrComment Then
14671467
EatExpression(tokenEnum, returnExpr)
1468+
If Not tokenEnum.IsEndOrComment Then
1469+
AddError(tokenEnum.Current, String.Format(ResourceHelper.GetString("UnexpectedTokenAtLocation"), tokenEnum.Current.Text))
1470+
End If
14681471
End If
14691472

14701473
Dim subroutine = SubroutineStatement.Current

Samples/Drawing Samples/Right-Angled Triangles/Form1.sb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
GetTriangles()
22
ListBox1.SelectedIndex = 1
3+
ListBox1.Focus()
34

4-
' ------------------------------------------------
55
Sub GetTriangles()
6-
sides = {}
7-
For i = 2 To 100
8-
i2 = i * i
9-
For j = 2 To i - 1
10-
j2 = j * j
11-
k = Math.SquareRoot(i2 - j2)
12-
If Math.Round(k) = k And Array.ContainsValue(sides[i], j) = False Then
13-
sides[i] = Array.AddItem(sides[i], k)
14-
ListBox1.AddItem(Text.Format("[1],[2],[3]", {j, k, i}))
15-
ContinueLoop
6+
For c = 1 To 100
7+
c2 = c * c
8+
For a = 1 To c - 1
9+
a2 = a * a
10+
b = Math.SquareRoot(c2 - a2)
11+
If Math.Truncate(b) = b Then
12+
ListBox1.AddItem(Text.Format("[1],[2],[3]", {a, b, c}))
1613
EndIf
1714
Next
1815
Next
1916
EndSub
2017

21-
22-
' ------------------------------------------------
2318
Sub ListBox1_OnSelection()
2419
sides = Text.Split(ListBox1.SelectedItem, ",", True, True)
25-
scale = 7
20+
scale = 6
2621
Label1.AddTriangle(
2722
0, Me.Height - 40,
2823
sides[2] * scale, Me.Height - 40,

Samples/Games/Ball Game/Form1.sb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SpeedX = 5
2-
SpeedY = 10
2+
SpeedY = 5
33
GameOver = False
44
Score = 0
55
RacketDelta = 15
@@ -10,44 +10,48 @@ RacketTimer.Pause()
1010
RacketTimer.OnTick = MoveRacket
1111

1212
Sub MoveBall()
13+
Ball.Left = Ball.Left + SpeedX
14+
If Ball.Right > Me.Width Then
15+
Ball.Right = Me.Width
16+
SpeedX = -SpeedX
17+
Sound.Play("boing.wav")
18+
ElseIf Ball.Left < 0 Then
19+
Ball.Left = 0
20+
SpeedX = -SpeedX
21+
Sound.Play("boing.wav")
22+
EndIf
23+
1324
Ball.Top = Ball.Top + SpeedY
14-
If GameOver And Ball.Top > Me.Height Then
25+
If Ball.Top > Me.Height Then
1526
Timer.Pause()
1627
Sound.Play("game_over.mp3")
17-
Me.ShowMessage("Your score = " + Score, "Game over")
18-
Return
28+
Me.ShowMessage("Your score = " + Score + ". Press space tp play again.", "Game over")
29+
ElseIf Ball.Top < 0 Then
30+
Ball.Top = 0
31+
SpeedY = -SpeedY
32+
Sound.Play("boing.wav")
1933
EndIf
2034

21-
If Ball.Bottom >= Racket.Top Then
35+
If GameOver = False And Ball.Bottom >= Racket.Top Then
2236
If Ball.Right >= Racket.Left
2337
And Ball.Left <= Racket.Right Then
2438
Ball.Bottom = Racket.Top
2539
SpeedY = -SpeedY
2640
Score = Score + 1
2741
Me.Text = Score
2842
Sound.Play("ball_hit.mp3")
29-
Else
43+
If Score Mod 10 = 0 Then
44+
SpeedX = SpeedX * 1.1
45+
SpeedY = SpeedY * 1.1
46+
EndIf
47+
ElseIf Ball.Top > Racket.Top + Racket.Height / 2 Then
3048
GameOver = True
49+
RacketTimer.Pause()
3150
EndIf
32-
33-
ElseIf Ball.Top < 0 Then
34-
Ball.Top = 0
35-
SpeedY = -SpeedY
36-
Sound.Play("boing.wav")
37-
EndIf
38-
39-
Ball.Left = Ball.Left + SpeedX
40-
If Ball.Right > Me.Width Then
41-
Ball.Right = Me.Width
42-
SpeedX = -SpeedX
43-
Sound.Play("boing.wav")
44-
ElseIf Ball.Left < 0 Then
45-
Ball.Left = 0
46-
SpeedX = -SpeedX
47-
Sound.Play("boing.wav")
4851
EndIf
4952
EndSub
5053

54+
5155
Sub Form_OnKeyDown()
5256
If GameOver Then
5357
If Keyboard.LastKey = Keys.Space Then
@@ -60,17 +64,13 @@ Sub Form_OnKeyDown()
6064
Timer.Resume()
6165
EndIf
6266

63-
Return
64-
EndIf
65-
66-
If Keyboard.LastKey = Keys.Left Then
67+
ElseIf Keyboard.LastKey = Keys.Left Then
6768
RacketDelta = -15
6869
RacketTimer.Resume()
6970
ElseIf Keyboard.LastKey = Keys.Right Then
7071
RacketDelta = 15
7172
RacketTimer.Resume()
7273
EndIf
73-
7474
EndSub
7575

7676
Sub Form_OnKeyUp()

Samples/Games/Ball Game/Form1.sb.gen

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
Me = "form1"
88
Ball = "form1.ball"
99
Racket = "form1.racket"
10-
_path = Program.Directory + "\Form1.xaml"
10+
_path = Program.Directory + "\form1.xaml"
1111
Form1 = Forms.LoadForm("Form1", _path)
1212
Form.SetArgsArr(form1, Stack.PopValue("_form1_argsArr"))
13-
Form.Show(Me)
14-
Form.Show(Me)
1513
'#Events{
1614
' Form1: OnKeyDown OnKeyUp
1715
'}

Samples/Games/Traffic Lights/Form1.sb

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@ HornSound = Sound.Load("1.mp3")
22
SrartEngineSound = Sound.Load("2.mp3")
33
SlowdownSound = Sound.Load("3.mp3")
44
MovingSound = Sound.Load("4.mp3")
5-
WasMoving = False
5+
6+
Speed = 0
7+
Timer.Interval = 20
68
Timer.Tick = MoveCar
7-
MaxTime = 0
9+
10+
Sub MoveCar()
11+
Car.Top = Car.Top - Speed
12+
If Car.Top < -Car.Height Then
13+
Car.Top = Me.Height
14+
EndIf
15+
EndSub
816

917
Sub RdoStop_OnCheck()
1018
If RdoStop.Checked Then
1119
RedLight.BackColor = Colors.Red
1220
HornSound.Play()
13-
WasMoving = False
14-
Timer.Pause()
15-
Car.AnimatePos(Car.Left, Car.Top, 0)
21+
Speed = 0
1622
Else
1723
RedLight.BackColor = Colors.DarkRed
1824
HornSound.Stop()
@@ -23,13 +29,12 @@ EndSub
2329
Sub RdoReady_OnCheck()
2430
If RdoReady.Checked Then
2531
YelloLight.BackColor = Colors.LightYellow
26-
If WasMoving Then
32+
If Speed > 0 Then
2733
SlowdownSound.Play()
28-
WasMoving = False
34+
Speed = 5
2935
Else
3036
SrartEngineSound.Play()
3137
EndIf
32-
MaxTime = 10000
3338
Else
3439
YelloLight.BackColor = "#FF858504"
3540
SlowdownSound.Stop()
@@ -41,8 +46,7 @@ Sub RdoGo_OnCheck()
4146
If RdoGo.Checked Then
4247
GreenLight.BackColor = Colors.LightGreen
4348
MovingSound.Play()
44-
WasMoving = True
45-
MaxTime = 5000
49+
Speed = 10
4650
MoveCar()
4751
Else
4852
GreenLight.BackColor = Colors.DarkGreen
@@ -51,13 +55,4 @@ Sub RdoGo_OnCheck()
5155
EndSub
5256

5357

54-
Sub MoveCar()
55-
Timer.Pause()
56-
If Car.Top <= -Car.Height Then
57-
Car.Top = Me.Height
58-
EndIf
59-
distanceRatio = (Car.Top + Car.Height) / (Me.Height + Car.Height)
60-
time = MaxTime * distanceRatio
61-
Car.AnimatePos(Car.Left, -Car.Height, time)
62-
Timer.Interval = time
63-
EndSub
58+

Samples/Math Samples/Multiplication table.sb

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,13 @@ For I = 1 To 12
22
For J = 1 To 12
33
TW.WriteFormatted(
44
"[1] x [2] = [3][4]",
5-
{PadRight(I), PadLeft(J), PadLeft2(I * J), Text.NewLine}
5+
{
6+
Text.PadRight(I, 2),
7+
Text.PadLeft(J, 2),
8+
Text.PadLeft(I * J, 3),
9+
Text.NewLine
10+
}
611
)
712
Next
813
TW.WriteLine("-------------------------")
914
Next
10-
11-
12-
' ------------------------------------------------
13-
Function PadLeft(txt)
14-
If txt.Length = 1 Then
15-
Return " " + txt
16-
EndIf
17-
Return txt
18-
EndFunction
19-
20-
' ------------------------------------------------
21-
Function PadLeft2(txt)
22-
If txt.Length = 1 Then
23-
Return " " + txt
24-
ElseIf txt.Length = 2 Then
25-
Return " " + txt
26-
EndIf
27-
Return txt
28-
EndFunction
29-
30-
' ------------------------------------------------
31-
Function PadRight(txt)
32-
If txt.Length = 1 Then
33-
Return txt + " "
34-
EndIf
35-
Return txt
36-
EndFunction

0 commit comments

Comments
 (0)
X Tutup