- 1
- 2
- 3
- 4
- 5
If Not Me.Opacity > 1 Then 'полный провал
Opacity = Opacity + 0.02
Else
Timer1.Enabled = False
End If
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−99
If Not Me.Opacity > 1 Then 'полный провал
Opacity = Opacity + 0.02
Else
Timer1.Enabled = False
End If
Часть кода из функции таймера
−110
Public Class Decoder
Dim arr_en() As String = {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "?", "@"}
Dim arr_ua() As String = {"й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ъ", "ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "є", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю", ".", ",", "'"}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Clear()
Dim t As Char
Dim ch As Char
Dim vv As String
For Each vv In TextBox1.Lines
For Each t In vv
For i As Integer = 0 To arr_en.Count - 1
ch = arr_en.GetValue(i)
If t = ch Then
t = arr_ua.GetValue(i)
Exit For
End If
Next
TextBox2.Text = TextBox2.Text & t
Next
TextBox2.Text = TextBox2.Text & vbCrLf
Next
End Sub
End Class
Декодер с английской раскладки за 5 минут.
−110
Dim num As Integer
Dim inp As Integer
Dim wrt As String
Dim liv As Integer
Sub Main()
liv = 3
Console.WriteLine("LIVES = " & liv)
pl:
If liv = 0 Then GoTo st
num = Fix(Rnd() * 5)
Console.WriteLine("ENTER NUMBER:")
inp = Console.ReadLine()
If inp < num Then
Console.WriteLine("GREATER")
liv = liv - 1
Console.WriteLine("LIVES = " & liv)
GoTo pl
End If
If inp > num Then
Console.WriteLine("LESS")
liv = liv - 1
Console.WriteLine("LIVES = " & liv)
GoTo pl
End If
If inp = num Then Console.WriteLine("YES!")
st:
Console.WriteLine("GAME OVER")
Console.WriteLine("ENTER ANY NUMBER TO EXIT")
inp = Console.ReadLine()
End Sub
Одна из моих первых "прог" на VB, написанная около 4х лет назад - "Угадай число".
−105
Public LettersB() As Char = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
Public LettersM() As Char = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
Public Numbers() As Char = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
<...>
Public Function GenLetterB() As String
GenLetterB = LettersB(rnd.Next(0, LettersB.Length - 1)).ToString
End Function
Public Function GenLetterM() As String
GenLetterM = LettersM(rnd.Next(0, LettersB.Length - 1)).ToString
End Function
Public Function GenNumber() As String
GenNumber = rnd.Next(0, 9).ToString
End Function
<...>
For i = 1 To numLen.Value
RndGen: curType = rnd.Next(0, 3)
Select Case curType
Case 0
If chkB.Checked = True Then
pass += GenLetterB()
rnd.Next(0, LettersB.Length - 1)
Else
GoTo RndGen
End If
Case 1
If chkM.Checked = True Then
pass += GenLetterM()
rnd.Next(0, LettersM.Length - 1)
Else
GoTo RndGen
End If
Case 2
If chkNum.Checked = True Then
pass += GenNumber()
rnd.Next(0, LettersM.Length - 1)
Else
GoTo RndGen
End If
Case Else
If chkNum.Checked = True Then
pass += GenNumber()
rnd.Next(0, LettersM.Length - 1)
Else
GoTo RndGen
End If
End Select
Next
Очень древний мой высер, ещё из тех времён, когда я писал на VB. Кстати, прога есть на сурсфордже, у неё достаточно много скачиваний и жалоб нету.
−81
Try
RichTextBox1.Text = int.OpenURL(adress & TextBox1.Text & units)
tmpStr = RichTextBox1.Text.Split(">")
Header = tmpStr(4).Split("<")
lblHeader.Text = Header(0)
CityName = Trim(Mid$(Header(0), 17, Len(Header(0)) - 16))
outCName = CityName
Codemass = tmpStr(43).Split(Chr(34))
CodeNum = CInt(Codemass(3))
tMass = tmpStr(43).Split(Chr(34))
WCmass = tmpStr(17).Split(Chr(34))
ATmass = tmpStr(18).Split(Chr(34))
outWindC = "W: " & WCmass(3) & "o," & WCmass(5) & unSpd
'outWCode = WCondition(CodeNum)
outWState = tMass(1) & ","
outTemp = tMass(5)
outTemp = outTemp & Mid(units, 4, 1)
outDate = tMass(7)
outHum = ATmass(1) & "%, " & ATmass(5) & unPre
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Мой старый парсер XML-погоды с Yahoo. System.Xml? Нет, не слышал.
−457
Public Function CheckForError(ByVal sRes1 As String, ByVal sRes2 As String, Optional ByVal sRes3 As String = "", Optional ByVal sRes4 As String = "", Optional ByVal sRes5 As String = "", Optional ByVal sRes6 As String = "", Optional ByVal sRes7 As String = "", Optional ByVal sRes8 As String = "", Optional ByVal sRes9 As String = "", Optional ByVal sRes10 As String = "", Optional ByVal sRes11 As String = "") As Boolean
Dim bRes As Boolean = True
If Not CheckForError(sRes1) Then
If Not CheckForError(sRes2) Then
If Not CheckForError(sRes3) Then
If Not CheckForError(sRes4) Then
If Not CheckForError(sRes5) Then
If Not CheckForError(sRes6) Then
If Not CheckForError(sRes7) Then
If Not CheckForError(sRes8) Then
If Not CheckForError(sRes9) Then
If Not CheckForError(sRes10) Then
If Not CheckForError(sRes11) Then
bRes = False
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Return bRes
End Function
Птицы летят на юг!
−174
Sub display(frm As Form)
Dim lvl As Boolean
Dim format As String
If (frm.optSex(0).value) Then
format = oI18n.translate("res_m")
format = Replace(format, "\n", vbCrLf, 1, -1, vbBinaryCompare)
format = Replace(format, "*", frm.cmbSchool.Text, 1, 1, vbTextCompare)
format = Replace(format, "*", frm.txtForm.Text, 1, 1, vbTextCompare)
format = Replace(format, "*", frm.txtName.Text, 1, 1, vbTextCompare)
format = Replace(format, "*", frm.txtSurname.Text, 1, 1, vbTextCompare)
lvl = False
For Each optLvl In frm.chkLevel
If (optLvl.value) Then
format = Replace(format, "*", oI18n.translate(optLvl.Tag & "_m"), 1, 1, vbTextCompare)
lvl = True
End If
Next optLvl
If (Not lvl) Then format = Replace(format, "*", oI18n.translate("Bad" & "_m"), 1, 1, vbTextCompare)
End If
If (frm.optSex(1).value) Then
format = oI18n.translate("res_f")
format = Replace(format, "\n", vbCrLf, 1, -1, vbBinaryCompare)
format = Replace(format, "*", frm.cmbSchool.Text, 1, 1, vbTextCompare)
format = Replace(format, "*", frm.txtForm.Text, 1, 1, vbTextCompare)
format = Replace(format, "*", frm.txtName.Text, 1, 1, vbTextCompare)
format = Replace(format, "*", frm.txtSurname.Text, 1, 1, vbTextCompare)
lvl = False
For Each optLvl In frm.chkLevel
If (optLvl.value) Then
format = Replace(format, "*", oI18n.translate(optLvl.Tag & "_f"), 1, 1, vbTextCompare)
End If
Next optLvl
If (Not lvl) Then format = Replace(format, "*", oI18n.translate("Bad" & "_f"), 1, 1, vbTextCompare)
End If
Dim dalykai As String
Dim first As Boolean
dalykai = ""
first = True
For Each chkFavorite In frm.chkFavorites
If (chkFavorite.value) Then dalykai = dalykai & IIf(first, vbCrLf, vbCrLf) & (chkFavorite.Caption)
first = False
Next chkFavorite
If (frm.chkFavoriteOther.value) Then dalykai = dalykai & IIf(first, vbCrLf, vbCrLf) & (frm.txtFavoriteOther.Text)
Dim b As Boolean
b = dalykai = ""
If (b) Then
If (frm.optSex(0).value) Then dalykai = oI18n.translate("nores_m")
If (frm.optSex(1).value) Then dalykai = oI18n.translate("nores_f")
End If
If (Not b) Then
If (frm.optSex(0).value) Then dalykai = oI18n.translate("res2_m") & dalykai
If (frm.optSex(1).value) Then dalykai = oI18n.translate("res2_f") & dalykai
End If
MsgBox (format & vbCrLf & dalykai)
End Sub
заполняем строку-шаблон, заменяя звездочки реальными данными
вот не было в VB6 printf-подобной функции ((
−166
Public Sub DBOpen(Optional sFullPath As String = "")
If sFullPath = "" Then sFullPath = sPath
Dim f As Integer
Dim l As Integer
Dim tmp As String
Dim sName As String
Dim sSurname As String
Dim sSex As String
Dim dBirthdate As Date
Dim sCity As String
Dim sStreet As String
l = 0
f = FreeFile
Open sFullPath For Input As #f
While Not EOF(f)
Line Input #f, tmp
l = l + 1
Wend
Close #f
If l > 0 Then
ReDim asDB(0 To l - 1) As clsCitizen
l = 0
f = FreeFile
Open sFullPath For Input As #f
While Not EOF(f)
Input #f, sName, sSurname, sSex, dBirthdate, sCity, sStreet
Set asDB(l) = New clsCitizen
asDB(l).sName = sName
asDB(l).sSurname = sSurname
asDB(l).sSex = sSex
asDB(l).dBirthdate = dBirthdate
asDB(l).sCity = sCity
asDB(l).sStreet = sStreet
l = l + 1
Wend
Close #f
End If
sPath = sFullPath
End Sub
за что я ненавижу VB6
а ведь по-другому никак = (
−166
Private Sub btnNew_Click()
Dim i As Integer
Dim asCopy() As clsCitizen
ReDim asCopy(LBound(modCitizen.asDB) To UBound(modCitizen.asDB)) As clsCitizen
For i = LBound(modCitizen.asDB) To UBound(modCitizen.asDB)
Set asCopy(i) = modCitizen.asDB(i)
Next i
ReDim modCitizen.asDB(UBound(modCitizen.asDB) + 1) As clsCitizen
For i = LBound(asCopy) To UBound(asCopy)
Set modCitizen.asDB(i) = asCopy(i)
Next i
Set modCitizen.asDB(UBound(modCitizen.asDB)) = New clsCitizen
modCitizen.asDB(UBound(modCitizen.asDB)).bNew = True
iRecNum = UBound(modCitizen.asDB)
RecordRead
UpdateControls
LockMe True
End Sub
вот через какое место мучительно вспоминал давно забытый, старый добрый VB6
процедура дополняет массив новым элементом
−100
Private Sub Combo1_Click()
Select Case Combo1.ListIndex
Case 0
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\RaZeR.jpg")
Case 1
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Serg.jpg")
Case 2
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Nikton.jpg")
Case 3
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Raider.jpg")
Case 4
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Andrew.jpg")
Case 5
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Gnum.jpg")
Case 6
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Iron Man.jpg")
Case 7
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Anakin.jpg")
Case 8
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Nuparu.jpg")
Case 9
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Deleted.jpg")
Case 10
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\LEGOlas.jpg")
Case 11
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Kit Fisto.jpg")
Case 12
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Banky.jpg")
Case 13
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Pazitiffniy.jpg")
Case 14
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\GenKen.jpg")
Case 15
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Dimanok.jpg")
Case 16
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Drakon.jpg")
Case 17
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\DJ Sim.jpg")
Case 18
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Obi-Van.jpg")
Case 19
enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\Vitalya.jpg")
Case 20
enemy1.Picture = LoadPicture("data/Rescaled/LukeSW.jpg")
Case 21
enemy1.Picture = LoadPicture("data/Rescaled/Smegorik.jpg")
Case 22
enemy1.Picture = LoadPicture("data/Rescaled/Vitalya.jpg")
Case 23
enemy1.Picture = LoadPicture("data/Rescaled/DJ Sim.jpg")
End Select
End Sub
Private Sub Combo2_Click()
Select Case Combo2.ListIndex
Case 0
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\RaZeR.jpg")
Case 1
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Serg.jpg")
Case 2
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Nikton.jpg")
Case 3
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Raider.jpg")
Case 4
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Andrew.jpg")
Case 5
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Gnum.jpg")
Case 6
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Iron Man.jpg")
Case 7
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Anakin.jpg")
Case 8
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Nuparu.jpg")
Case 9
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Deleted.jpg")
Case 10
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\LEGOlas.jpg")
Case 11
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Kit Fisto.jpg")
Case 12
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Banky.jpg")
Case 13
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Pazitiffniy.jpg")
Case 14
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\GenKen.jpg")
Case 15
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Dimanok.jpg")
Case 16
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\Drakon.jpg")
Case 17
enemy2.Picture = LoadPicture(App.Path & "\data\Rescaled\DJ Sim.jpg")
Тот же источник, что и #5201. Загрузка картинок из тех самых комбобоксов. А ведь можно было enemy1.Picture = LoadPicture(App.Path & "\data\Rescaled\" & Combo1.SelectedItem & ".jpg").