برنامه ي مهمان دار پرواز در هواپيما

در اين برنامه اول بايد 8 تا command درست كنيد كه اسم اونها رو واستون گذاشتم :

1.cmdassign

2.cmdtime

3.exit

4.cmddate

5.cmdcity

6.cmdciti

7.cmdadd

8.cmdremove

بعد از گذاشتن command ها حالا بايد 2 تا combo box و 1 عدد list box  بزاريد به اسمهاي :

combo box:

1.cbomeal

2.cboseat

list box:

1.lstcity

و بعد از انجام همه ي اين كارها بايد تكه كدهاي زير بنويسيد:


lstcity.Clear
cboseat.Clear
cbomeal.Clear

End Sub

Private Sub cmdadd_Click()
cbomeal.AddItem InputBox("please enter name of food", "add food")

End Sub

Private Sub cmdassign_Click()
Dim message As String
message = "destination:" + lstcity.Text + vbCr
message = message + "seatlocation:" + cboseat.Text + vbCr
message = message + "meal pereference:" + cbomeal.Text + vbCr
message = message + "time:" + cmddate.Caption + vbCr
message = message + "date:" + cmdtime.Caption + vbCr
MsgBox message, vbOKOnly + vbInformation, "your assignment"
End Sub

Private Sub cmdciti_Click()
lstcity.RemoveItem (lstcity.ListIndex)
End Sub

Private Sub cmdcity_Click()
lstcity.AddItem InputBox("please write a name of city", "addcity")
End Sub

Private Sub cmddate_Click()
cmddate.Caption = CStr(Date)
End Sub

Private Sub cmdremove_Click()
cbomeal.RemoveItem (cbomeal.ListIndex)




End Sub

Private Sub cmdtime_Click()
cmdtime.Caption = CStr(Time)
End Sub

Private Sub exit_Click()
End

End Sub

رسم دايره هرجا از فرم كه دلتون ميخواد

اول بايد يه فرم درست كنيد بعد اين كدها رو توش بنويسي

Option Explicit
Dim X1 As Single, Y1 As Single, X2 As Single, Y2 As Single

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'Refresh your start variables
    X1 = X
    Y1 = Y
    X2 = X
    Y2 = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        'Set the DrawMode to 6 indicates the next circle drawn will be an inverted line.
        'This renders the circle invisible
        'form1.DrawWidth = form1.DrawWidth + 10
        Form1.DrawMode = 6
        If Abs(X1 - X2) > 0 Then
                'This draws an inverted circle over the previous line. Basically erasing it
                Form1.Line ((X1 - 15) - Abs(X1 - X2), (Y1 - 15) - Abs(X1 - X2))-((X1 + 15) + Abs(X1 - X2), (Y1 + 15) + Abs(X1 - X2)), , B
                Circle (X1, Y1), Abs(X2 - X1)
                'Draw  line
                'form1.DrawWidth = form1.DrawWidth - 10
                'DrawMode 13 is the default copy pen setting
                'Form1.DrawMode = 13
                'Refresh line ending values to current position
        End If
        X2 = X
        Y2 = Y
        If Abs(X1 - X2) > 0 Then Form1.Line ((X1 - 15) - Abs(X1 - X2), (Y1 - 15) - Abs(X1 - X2))-((X1 + 15) + Abs(X1 - X2), (Y1 + 15) + Abs(X1 - X2)), , B
        Circle (X1, Y1), Abs(X1 - X2)
        'Draw new line
    End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Form1.Line ((X1 - 15) - Abs(X1 - X2), (Y1 - 15) - Abs(X1 - X2))-((X1 + 15) + Abs(X1 - X2), (Y1 + 15) + Abs(X1 - X2)), , B
    Form1.DrawMode = 13
    Circle (X1, Y1), Abs(X - X1), RGB(215, 0, 0)
End Sub

برنامه ي piano براي ويژوال بيسيك

قسمت اول - ماژول

Option Explicit

Public Const MAXPNAMELEN = 32             ' Maximum product name length

' Error values for functions used in this sample. See the function for more information
Public Const MMSYSERR_BASE = 0
Public Const MMSYSERR_BADDEVICEID = (MMSYSERR_BASE + 2)     ' device ID out of range
Public Const MMSYSERR_INVALPARAM = (MMSYSERR_BASE + 11)     ' invalid parameter passed
Public Const MMSYSERR_NODRIVER = (MMSYSERR_BASE + 6)        ' no device driver present
Public Const MMSYSERR_NOMEM = (MMSYSERR_BASE + 7)           ' memory allocation error

Public Const MMSYSERR_INVALHANDLE = (MMSYSERR_BASE + 5)     ' device handle is invalid
Public Const MIDIERR_BASE = 64
Public Const MIDIERR_STILLPLAYING = (MIDIERR_BASE + 1)      ' still something playing
Public Const MIDIERR_NOTREADY = (MIDIERR_BASE + 3)          ' hardware is still busy
Public Const MIDIERR_BADOPENMODE = (MIDIERR_BASE + 6)       ' operation unsupported w/ open mode

Type MIDIOUTCAPS
   wMid As Integer                   ' Manufacturer identifier of the device driver for the MIDI output device
                                     ' For a list of identifiers, see the Manufacturer Indentifier topic in the
                                     ' Multimedia Reference of the Platform SDK.
  
   wPid As Integer                   ' Product Identifier Product of the MIDI output device. For a list of
                                     ' product identifiers, see the Product Identifiers topic in the Multimedia
                                     ' Reference of the Platform SDK.
  
   vDriverVersion As Long            ' Version number of the device driver for the MIDI output device.
                                     ' The high-order byte is the major version number, and the low-order byte is
                                     ' the minor version number.
                                    
   szPname As String * MAXPNAMELEN   ' Product name in a null-terminated string.
  
   wTechnology As Integer            ' One of the following that describes the MIDI output device:
                                     '     MOD_FMSYNTH-The device is an FM synthesizer.
                                     '     MOD_MAPPER-The device is the Microsoft MIDI mapper.
                                     '     MOD_MIDIPORT-The device is a MIDI hardware port.
                                     '     MOD_SQSYNTH-The device is a square wave synthesizer.
                                     '     MOD_SYNTH-The device is a synthesizer.
                                    
   wVoices As Integer                ' Number of voices supported by an internal synthesizer device. If the
                                     ' device is a port, this member is not meaningful and is set to 0.
                                    
   wNotes As Integer                 ' Maximum number of simultaneous notes that can be played by an internal
                                     ' synthesizer device. If the device is a port, this member is not meaningful
                                     ' and is set to 0.
                                    
   wChannelMask As Integer           ' Channels that an internal synthesizer device responds to, where the least
                                     ' significant bit refers to channel 0 and the most significant bit to channel
                                     ' 15. Port devices that transmit on all channels set this member to 0xFFFF.
                                    
   dwSupport As Long                 ' One of the following describes the optional functionality supported by
                                     ' the device:
                                     '     MIDICAPS_CACHE-Supports patch caching.
                                     '     MIDICAPS_LRVOLUME-Supports separate left and right volume control.
                                     '     MIDICAPS_STREAM-Provides direct support for the midiStreamOut function.
                                     '     MIDICAPS_VOLUME-Supports volume control.
                                     '
                                     ' If a device supports volume changes, the MIDICAPS_VOLUME flag will be set
                                     ' for the dwSupport member. If a device supports separate volume changes on
                                     ' the left and right channels, both the MIDICAPS_VOLUME and the
                                     ' MIDICAPS_LRVOLUME flags will be set for this member.
End Type

Declare Function midiOutGetNumDevs Lib "winmm" () As Integer

Declare Function midiOutGetDevCaps Lib "winmm.dll" Alias "midiOutGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As MIDIOUTCAPS, ByVal uSize As Long) As Long

Declare Function midiOutClose Lib "winmm.dll" (ByVal hMidiOut As Long) As Long

Declare Function midiOutOpen Lib "winmm.dll" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long


Declare Function midiOutShortMsg Lib "winmm.dll" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long


قسمت دوم - كد فرم


Option Explicit

Const INVALID_NOTE = -1     ' Code for keyboard keys that we don't handle

Dim numDevices As Long      ' number of midi output devices
Dim curDevice As Long       ' current midi device
Dim hmidi As Long           ' midi output handle
Dim rc As Long              ' return code
Dim midimsg As Long         ' midi output message buffer
Dim channel As Integer      ' midi output channel
Dim volume As Integer       ' midi volume
Dim baseNote As Integer     ' the first note on our "piano"
' Set the value for the starting note of the piano
Private Sub base_Click()
   Dim s As String
   Dim i As Integer
   s = InputBox("Enter the new base note for the keyboard (0 - 111)", "Base note", CStr(baseNote))
   If IsNumeric(s) Then
      i = CInt(s)
      If (i >= 0 And i < 112) Then
         baseNote = i
      End If
   End If
End Sub

' Select the midi output channel
Private Sub chan_Click(Index As Integer)
   chan(channel).Checked = False
   channel = Index
   chan(channel).Checked = True
End Sub

' Open the midi device selected in the menu. The menu index equals the
' midi device number + 1.
Private Sub device_Click(Index As Integer)
   device(curDevice + 1).Checked = False
   device(Index).Checked = True
   curDevice = Index - 1
   rc = midiOutClose(hmidi)
   rc = midiOutOpen(hmidi, curDevice, 0, 0, 0)
   If (rc <> 0) Then
      MsgBox "Couldn't open midi out, rc = " & rc
   End If
End Sub
' If user presses a keyboard key, start the corresponding midi note
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   StartNote NoteFromKey(KeyCode)
End Sub
' If user lifts a keyboard key, stop the corresponding midi note
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
   StopNote NoteFromKey(KeyCode)
End Sub
Private Sub Form_Load()
   Dim i As Long
   Dim caps As MIDIOUTCAPS
  
   ' Set the first device as midi mapper
   device(0).Caption = "MIDI Mapper"
   device(0).Visible = True
   device(0).Enabled = True
  
   ' Get the rest of the midi devices
   numDevices = midiOutGetNumDevs()
   For i = 0 To (numDevices - 1)
      midiOutGetDevCaps i, caps, Len(caps)
      device(i + 1).Caption = caps.szPname
      device(i + 1).Visible = True
      device(i + 1).Enabled = True
   Next
  
   ' Select the MIDI Mapper as the default device
   device_Click (0)
  
   ' Set the default channel
   channel = 0
   chan(channel).Checked = True
  
   ' Set the base note
   baseNote = 60
  
   ' Set volume range
   volume = 127
   vol.Min = 127
   vol.Max = 0
   vol.Value = volume
End Sub
Private Sub Form_Unload(Cancel As Integer)
   ' Close current midi device
   rc = midiOutClose(hmidi)
End Sub
' Start a note when user click on it
Private Sub key_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
   StartNote (Index)
End Sub
' Stop the note when user lifts the mouse button
Private Sub key_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
   StopNote (Index)
End Sub
' Press the button and send midi start event
Private Sub StartNote(Index As Integer)
   If (Index = INVALID_NOTE) Then
      Exit Sub
   End If
   If (key(Index).Value = 1) Then
      Exit Sub
   End If
   key(Index).Value = 1
   midimsg = &H90 + ((baseNote + Index) * &H100) + (volume * &H10000) + channel
   midiOutShortMsg hmidi, midimsg
End Sub
' Raise the button and send midi stop event
Private Sub StopNote(Index As Integer)
   If (Index = INVALID_NOTE) Then
      Exit Sub
   End If
   key(Index).Value = 0
   midimsg = &H80 + ((baseNote + Index) * &H100) + channel
   midiOutShortMsg hmidi, midimsg
End Sub
' Get the note corresponding to a keyboard key
Private Function NoteFromKey(key As Integer)
   NoteFromKey = INVALID_NOTE
   Select Case key
   Case vbKeyZ
      NoteFromKey = 0
   Case vbKeyS
      NoteFromKey = 1
   Case vbKeyX
      NoteFromKey = 2
   Case vbKeyD
      NoteFromKey = 3
   Case vbKeyC
      NoteFromKey = 4
   Case vbKeyV
      NoteFromKey = 5
   Case vbKeyG
      NoteFromKey = 6
   Case vbKeyB
      NoteFromKey = 7
   Case vbKeyH
      NoteFromKey = 8
   Case vbKeyN
      NoteFromKey = 9
   Case vbKeyJ
      NoteFromKey = 10
   Case vbKeyM
      NoteFromKey = 11
   Case 188 ' comma
      NoteFromKey = 12
   Case vbKeyL
      NoteFromKey = 13
   Case 190 ' period
      NoteFromKey = 14
   Case 186 ' semicolon
      NoteFromKey = 15
   Case 191 ' forward slash
      NoteFromKey = 16
   End Select

End Function
' Set the volume
Private Sub vol_Change()
   volume = vol.Value
End Sub

 آموزش برنامه ای که عددی را گرفته و مغلوب آن را نمایش می دهد .

برنامه ای که عددی را گرفته و مغلوب آن را نمایش می دهد .

دانلود

آموزش برنامه ای که کپشن فرم را از ورودی دریافت می کند .

برنامه ای که کپشن فرم را از ورودی دریافت می کند

دانلود(84.7حجم)

شماره ي ماه را از ورودي ميگيرد سپس تعداد روزهاي آن ماه را چاپ مي كند

Private Sub Command1_Click()
n = Val(Text1.Text)
If n = 12 Then
Label1.Caption = "29 Days"
Else
Label1.Caption = (31 - (n \ 7)) & "Days"
End If
End Sub

nامين روز سال را از ورودي مي گيرد و تاريخ مربوطه را چاپ مي كند

Private Sub Command1_Click()
n = Val(Text1.Text)
Select Case n
Case 1 To 365
Case Else: MsgBox "enter number 1-365"
End Select
k = n \ 186
m = ((n - 1 - 6 * k) \ (31 - k)) + 1
r = n - (m - 1) * (31 - m \ 7) - 6 * (m \ 7)
Label1.Caption = Year(Now) - 621 & "/" & m & "/" & r
End Sub

شماره ي روز فصل

Private Sub Command1_Click()
n = Val(Text1.Text)
If n = 4 Then
Label1.Caption = "89 days"
Else
Label1.Caption = (93 - 3 * (n \ 3)) & "days"
End If
End Sub

رسم مربع

Private Sub Command1_Click()
For k = 0 To 3
If k Mod 2 = 0 Then
X1 = 0
Y1 = (k * 1) * 360
X2 = X1 + 960
Y2 = Y1 + 360
s = 960
For i = 1 To 4
Line (X1, Y1)-(X2, Y2), , B
X1 = X1 + 960
X2 = X2 + s
Next
Else
X1 = -480
Y1 = Y2
X2 = X1 + 960
Y2 = Y1 + 360
For i = 1 To 4
Line (X1, Y1)-(X2, Y2), , B
X1 = X1 + 960
X2 = X2 + 960
Next
End If
Next
Line (0, 0)-(960 * 4, 360 * 4), , B
End Sub

زمان سنج ديجيتالي

Dim h, m, s As Integer

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Command3_Click()
h = 0: m = 0: s = 0
Label1.Caption = "00:00:00"
Timer1.Enabled = False
End Sub

Private Sub Form_Load()
h = 0: m = 0: s = 0
Timer1.Enabled = False
Timer1.Interval = 1000
Label1.Caption = "00:00:00"
End Sub

Private Sub Timer1_Timer()
s = s + 1
If s = 60 Then
s = 0: m = m + 1
End If
If m = 60 Then
m = 0: h = h + 1
End If
t = h & " : " & m & " ; " & s
Label1.Caption = Format(t, "hh:mm:ss")
End Sub

باز کردن رجیستری فقط با یک خط کد

در این برنامه شما فقط با یک خط می توانید برنامه ی run رو باز کنید با این تفاوت که temp رو باز نمی کنه

Private Sub Command1_Click()
Shell Text1.Text, vbNormalFocus
End Sub

در این برنامه شما نیاز به یک command و  textbox دارید

بعد از درست کردن برنامه کلمه ی regedit را تایپ کنید و رجستری رو باز کنید

طريقه ساختن ماشين حساب

طريقه ساخت ماشین حساب با برنامه نویسی ویژوال بیسیک

دانلود مقاله

برنامه ي تبديل تاريخ

  تبديل تاریخ هجری شمسی (ایرانی) به میلادی، هبرو و هجری قمری

تبدیل واحدهای مختلف تاریخی به هم همواره یکی از پروسه های مشکل ساز برای برنامه نویسان میباشد چرا که معمولا برای تبدیل مبدا های مختلف تاریخی نیاز به الگوریتم های پیچیده میباشد تا تمام ریزه کاریها را در نظر بگیرد. در اینجا دو کد برای زبان ویژوال بیسیک ارائه میشود که تقریبا جزو مبدلهای قوی تاریخ هستند. مخصوصا کد دوم که دارای کارایی های بسیار زیادی برای تبدیل تاریخهای مختلف به هم از قبیل هجری شمسی (تاریخ ایرانی)، میلادی، هبرو، هجری قمری را دارا میباشد. در برنامه اجرائی فقط قسمت بسیار اندکی از توانایی های این برنامه نمایش داده شده است و این کد قابلیت محاسبه تعطیلات رسمی (از قبیل اعیاد و ...). در این کد محاسبات تاریخ با در نظر گرفتن سالهای کبیسه میباشد. این سورس را من از سایت یکی از افراد علاقه مند به تاریخ در ایرلند (اگر اشتباه نکنم) گرفتم . امیدوارم این کدها قابل استفاده باشد.


دانلود:برنامه اجرائی (52 کیلوبایت)

دانلود:سورس برنامه به صورت زیپ شده (21 کیلوبایت)

برنامه تبديل تاريخ شمسي به تاريخ ميلادي

برنامه تبديل تاريخ شمسي به تاريخ ميلادي

تبدیل واحدهای مختلف تاریخی به هم همواره یکی از پروسه های مشکل ساز برای برنامه نویسان میباشد چرا که معمولا برای تبدیل مبدا های مختلف تاریخی نیاز به الگوریتم های پیچیده میباشد تا تمام ریزه کاریها را در نظر بگیرد. در اینجا دو کد برای زبان ویژوال بیسیک ارائه میشود که تقریبا جزو مبدلهای قوی تاریخ هستند. مخصوصا کد دوم که دارای کارایی های بسیار زیادی برای تبدیل تاریخهای مختلف به هم از قبیل هجری شمسی (تاریخ ایرانی)، میلادی، هبرو، هجری قمری را دارا میباشد. در برنامه اجرائی فقط قسمت بسیار اندکی از توانایی های این برنامه نمایش داده شده است و این کد قابلیت محاسبه تعطیلات رسمی (از قبیل اعیاد و ...). در این کد محاسبات تاریخ با در نظر گرفتن سالهای کبیسه میباشد. این سورس را من از سایت یکی از افراد علاقه مند به تاریخ در ایرلند (اگر اشتباه نکنم) گرفتم . امیدوارم این کدها قابل استفاده باشد.

دانلود:برنامه اجرائی (32 کیلوبایت)

دانلود:سورس برنامه به صورت زیپ شده (5 کیلوبایت)