1. مهمان گرامی، جهت ارسال پست، دانلود و سایر امکانات ویژه کاربران عضو، ثبت نام کنید.
    بستن اطلاعیه

یه سری آموزش های فوق العاده جالب برای دوستان عزیز

شروع موضوع توسط hector2141 ‏10/9/12 در انجمن Visual Basic

  1. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    اینو دیگه فکر کنم همه بلد باشن :
    چگونگی ایجاد منو برای کلیک راست...
    خوب ابتدا توسط Menu Editor منو و تعدادی SubMenu (زیر منو) ایجاد کرده و خاصیت Visible منو (فقط منو) را غیر فعال میکنیم
    حالا فرض میکنیم که می خواهیم منو را برای هنگامیکه بر روی فرم راست کلیک کردیم ظاهر کنیم , کد زیر را در Event (ٍرویداد) MouseDown می نویسیم :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    [/TD]
    [TD="class: code"]Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    <i>'Button = 1 :::>>> For LeftClick
    </i> <i>'Button = 2 :::>> For RightClick
    </i> If Button = 2 Then
    PopupMenu MnuFile
    End If

    End Sub

    [/TD]
    [/TR]
    [/TABLE]



    شما می توانید منوی کلیک راست رو برای هر عنصری که رویداد MouseDown رو داره پیاده سازی کنید .
     
  2. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    می خواهم چگونگی ساخت یک Splash Screen برای برنامه هایی که مینویسیم را براتون شرح بدم . خوب باز هم باید توابع مورد نیاز را فراخوانی کرده و همچنین ثوایت مورد نیاز را تعریف کنیم
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [/TD]
    [TD="class: code"]Const LWA_COLORKEY = &H1
    Const LWA_ALPHA = &H2
    Const GWL_EXSTYLE = (-20)
    Const WS_EX_LAYERED = &H80000
    Private Declare Function GetWindowLong Lib "user32" Alias _
    "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias _
    "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal _
    dwNewLong As Long) As Long
    Private Declare Function SetLayeredWindowAttributes Lib _
    "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha _
    As Byte, ByVal dwFlags As Long) As Long

    [/TD]
    [/TR]
    [/TABLE]



    نوع نمایش این Splash Screen به گونه ای است که میزان شفافیت فرم آن از 0 به 255 رسیده و دوباره کاهش یافته به صفر می رسد (یا بعبارت دیگر از حالت نامرئی به شفافیت کامل رسیده و دوباره از شفافیت آن کاسته شده و نامرئی می شود ) . خوب تنها Control که برای این برنامه نیاز داریمTimer می باشد . کدی که در Form_Load می بینید باعث می شود که فرم در ابتدای امر نامرئی باشد چون مقدار bAlfa آنرا 0 داده ام
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [/TD]
    [TD="class: code"]Private Sub Form_Load()

    Dim Ret As Long
    <i>'Set the window style to 'Layered'
    </i> Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
    Ret = Ret Or WS_EX_LAYERED
    SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
    <i> 'SetLayeredWindowAttributes Me.hWnd,0,(0-255),LWA_ALPHA
    </i> SetLayeredWindowAttributes Me.hWnd,0,0,LWA_ALPHA
    Timer1.interval = 1
    End
    End Sub

    [/TD]
    [/TR]
    [/TABLE]


    در مرحله بعد برای اینکه فرم از حالت نامرئی به مرئی برسد (یعنی مقدار آن از 0 به 255 برسد) یک حلقه For نوشتم . حال برای اینکه فرم دوباره از حالت مرئی به نامرئی برشد یک حلقه For دیگر با گام افزایش -1 نوشتم تا مقدار آنرا کاهش دهد .
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [/TD]
    [TD="class: code"]Private Sub Timer1_Timer()

    For i = 1 To 255
    SetLayeredWindowAttributes Me.hWnd,0,CByte(i),LWA_ALPHA
    Next i

    For i = 255 To 1 Step -1
    SetLayeredWindowAttributes Me.hWnd,0,CByte(i),LWA_ALPHA
    Next i

    Timer1.Enabled = False

    End Sub

    [/TD]
    [/TR]
    [/TABLE]



    (*) یک نکته : این برنامه در سیستم عاملهای windows 2000 به بعد قابل اجراست , زیرا توابع مورد استفاده در این برنامه در ویندوزهای 98 و 95 وجود ندارد .
     
  3. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    :: این بر نامه با استفاده از API مقدار حافظه فیزیکی و مجازی و ... را برایتان نمایش می ده . این برنامه خیلی ساده است و توضیحی هم ندارم که براش بدم چون اگه یه نگاه به سورسش بندازید می فهمید که چیز خاصی نداره .
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    [/TD]
    [TD="class: code"]Private Type Memory
    Length As Long
    MemoryLoad As Long
    TotalPhysMemory As Long
    AvailablePhysMemory As Long
    TotalPageFile As Long
    AvailPageFile As Long
    TotalVirtualMemory As Long
    AvailableVirtualMemory As Long
    End Type

    Private Declare Sub GlobalMemoryStatus Lib "kernel32" (M As Memory)

    Private Sub Timer1_Timer()
    Dim M As Memory
    GlobalMemoryStatus M
    '*************************************************
    LblAvlMem.Caption = Format(CDbl(M.AvailablePhysMemory / 1048576), "#.## MB")
    LblTotalPhMem.Caption = Format(CDbl(M.TotalPhysMemory / 1048576), "#.## MB")
    LblUsedMemory.Caption = Format(CDbl((M.TotalPhysMemory - M.AvailablePhysMemory) / 1048576), "#.## MB")
    LblPercentPhMem.Caption = Format(CDbl((M.AvailablePhysMemory / M.TotalPhysMemory)), "##.#%")
    '*************************************************
    LblVirtualMem.Caption = Format(CDbl(M.AvailableVirtualMemory / 1048576), "#.## MB")
    LblTotalVirtualMem.Caption = Format(CDbl(M.TotalVirtualMemory / 1048576), "#.## MB")
    LblUsedVirtualMem.Caption = Format(CDbl((M.TotalVirtualMemory - M.AvailableVirtualMemory) / 1048576), "#.## MB")
    LblPercentVirtualMem.Caption = Format(CDbl((M.AvailableVirtualMemory / M.TotalVirtualMemory)), "##.#%")
    '*************************************************

    End Sub

    [/TD]
    [/TR]
    [/TABLE]
     
  4. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    تابعی برای تعیین باز بودن پروسس
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    [/TD]
    [TD="class: code"]Const MAX_PATH = 260
    Const TH32CS_SNAPPROCESS = 2&

    Private Type PROCESSENTRY32
    lSize As Long
    lUsage As Long
    lProcessId As Long
    lDefaultHeapId As Long
    lModuleId As Long
    lThreads As Long
    lParentProcessId As Long
    lPriClassBase As Long
    lFlags As Long
    sExeFile As String * MAX_PATH
    End Type

    Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)

    Private Declare Function CreateToolhelpSnapshot Lib "kernel32" _
    Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, _
    ByVal lProcessId As Long) As Long

    Private Declare Function ProcessFirst Lib "kernel32" _
    Alias "Process32First" (ByVal hSnapshot As Long, _
    uProcess As PROCESSENTRY32) As Long

    Private Declare Function ProcessNext Lib "kernel32" _
    Alias "Process32Next" (ByVal hSnapshot As Long, _
    uProcess As PROCESSENTRY32) As Long
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
    ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long

    Function IsProcessAlive(pId As Long) As Boolean
    Dim sExeName As String
    Dim sPid As String
    Dim sParentPid As String
    Dim lSnapShot As Long
    Dim r As Long
    Dim uProcess As PROCESSENTRY32

    Dim fProc As Long
    IsProcessAlive = False
    lSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    uProcess.lSize = Len(uProcess)
    r = ProcessFirst(lSnapShot, uProcess)
    Do While r
    If uProcess.lProcessId = pId Then
    IsProcessAlive = True
    Exit Do
    End If
    r = ProcessNext(lSnapShot, uProcess)
    Loop
    CloseHandle (lSnapShot)

    End Function

    [/TD]
    [/TR]
    [/TABLE]


    --------------------
    بستن Process بر اساس Pid
    تابعی برای بستن پروسس بر اساس آی دی پروسس
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [/TD]
    [TD="class: code"]Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
    ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
    Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, _
    ByVal uExitCode As Long) As Long

    Public Sub EndProcessPerID(fProc As Long)

    Dim mProcID As Long
    mProcID = OpenProcess(1&, -1&, fProc)
    TerminateProcess mProcID, 0&

    End Sub

    [/TD]
    [/TR]
    [/TABLE]


    --------------------
    hWnd to Process ID
    تابعی برای تبدیل hWnd به Pid
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    [/TD]
    [TD="class: code"]Private Const GW_HWNDNEXT = 2

    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long

    Public Function hWndToPid(ByVal My_hwnd As Long) As Long
    Dim test_hwnd As Long
    Dim test_pid As Long
    Dim test_thread_id As Long

    " Get the first window handle.
    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)

    " Loop until we find the target or we run out
    " of windows.
    Do While test_hwnd <> 0
    " See if this window has a parent. If not,
    " it is a top-level window.
    If GetParent(test_hwnd) = 0 Then
    " This is a top-level window. See if
    " it has the target instance handle.
    test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)

    If test_hwnd = My_hwnd Then
    " This is the target.
    hWndToPid = test_pid
    Exit Do
    End If
    End If

    " Examine the next window.
    test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
    End Function

    [/TD]
    [/TR]
    [/TABLE]


    --------------------
    ProcessID to hWnd
    تابعی برای تبدیل Pid به hwnd
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    [/TD]
    [TD="class: code"]Private Const GW_HWNDNEXT = 2

    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long

    " Return the window handle for an instance handle.
    Public Function PidTohWnd(ByVal target_pid As Long) As Long
    Dim test_hwnd As Long
    Dim test_pid As Long
    Dim test_thread_id As Long

    " Get the first window handle.
    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)

    " Loop until we find the target or we run out
    " of windows.
    Do While test_hwnd <> 0
    " See if this window has a parent. If not,
    " it is a top-level window.
    If GetParent(test_hwnd) = 0 Then
    " This is a top-level window. See if
    " it has the target instance handle.
    test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)

    If test_pid = target_pid Then
    " This is the target.
    PidTohWnd = test_hwnd
    Exit Do
    End If
    End If

    " Examine the next window.
    test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
    End Function

    [/TD]
    [/TR]
    [/TABLE]
     
  5. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    نامرئی کردن قسمتهای اضافی فرم

    این کد خیلی کاربردیه، حتماً به دردتون مبخوره. این کد باعث میشه که گوشه ها و قسمتهای اضافی فرم حذف بشه و فقط جاهایی که شما میخواید، قابل رویت باشه. مانند اسکین های Windows Media Player که بسیار زیباست.

    یک پروژه جدید باز کنید و داخل فرمتون یک شئ Shape بذارید و کد زیر رو تو قسمت جنرال فرمتون کپی کنید :

    Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

    Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

    Const LWA_COLORKEY = &H1

    Const GWL_EXSTYLE = (-20)

    Const WS_EX_LAYERED = &H80000

    Const BM_SETSTATE = &HF3

    Private Sub Form_Load()

    Dim Ret As Long

    Dim CLR As Long

    Me.BackColor = RGB(1, 1, 1) '

    CLR = Me.BackColor

    Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)

    Ret = Ret Or WS_EX_LAYERED

    SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret

    SetLayeredWindowAttributes Me.hWnd, CLR, 0, LWA_COLORKEY

    End Sub
    --------------------
    نامرئی کردن قسمتهای اضافی فرم

    این کد خیلی کاربردیه، حتماً به دردتون مبخوره. این کد باعث میشه که گوشه ها و قسمتهای اضافی فرم حذف بشه و فقط جاهایی که شما میخواید، قابل رویت باشه. مانند اسکین های Windows Media Player که بسیار زیباست.

    یک پروژه جدید باز کنید و داخل فرمتون یک شئ Shape بذارید و کد زیر رو تو قسمت جنرال فرمتون کپی کنید :

    Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

    Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

    Const LWA_COLORKEY = &H1

    Const GWL_EXSTYLE = (-20)

    Const WS_EX_LAYERED = &H80000

    Const BM_SETSTATE = &HF3

    Private Sub Form_Load()

    Dim Ret As Long

    Dim CLR As Long

    Me.BackColor = RGB(1, 1, 1) '

    CLR = Me.BackColor

    Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)

    Ret = Ret Or WS_EX_LAYERED

    SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret

    SetLayeredWindowAttributes Me.hWnd, CLR, 0, LWA_COLORKEY

    End Sub
    --------------------
    اعمال مشخصه RightToLeft به کنترلهایی که فاقد این مشخصه اند

    در این روش شما میتونید به هر کنترلی این مشخصه رو اعمال کنید، حتی کنترلهایی که فاقد این مشخصه هستند مثل DirListBox به صورت از راست به چپ در میان. درضمن اگه با فرمتون اینکارو بکنید میبینید که واقعاً به صورت از راست به چپ درمیاد یعنی دکمه Close، Minimize و Maximize از سمت راست فرم به سمت چپ فرم انتقال پیدا میکنن.

    یک پروژه جدید باز کنید و یک DirListBox به فرمتون اضافه کنید و کد زیر رو تو قسمت جنرال فرمتون کپی کنید :

    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Private Sub Form_Load()

    SetWindowLong Me.hWnd, -20, GetWindowLong(Me.hWnd, -20) Or &H400000

    SetWindowLong Dir1.hWnd, -20, GetWindowLong(Dir1.hWnd, -20) Or &H400000

    End Sub
     
  6. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    برنامه ی زیر 10 عدد رو میگیره و تعیین میکنه کدوم زوج هست و کدوم فرد :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    [/TD]
    [TD="class: code"]Private Sub Command13_Click() '16

    Cls

    Dim i As Integer, n As Integer

    For i = 1 To 10

    n = InputBox("Enter the num")

    Print n; Tab(10); IIf(n Mod 2 = 0, "Even", "Odd")

    Next

    End Sub

    [/TD]
    [/TR]
    [/TABLE]



    ------------------------------------------------------------------------
    برنامه زیر 20 عدد را خوانده و بزرگترین و کوچکترین آنها را نمایش میدهد :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    [/TD]
    [TD="class: code"]Private Sub Command15_Click()

    Dim min As Integer, max As Integer, n As Integer, i As Integer

    For i = 1 To 20

    n = InputBox("Enter a num")

    If i = 1 Then min = n

    If n > max Then max = n

    If n < min Then min = n

    Next

    MsgBox "Max: " & max & " Min: " & min

    End Sub

    [/TD]
    [/TR]
    [/TABLE]
     
  7. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    برنامه زیر عدد چها رقمی فاقد صفر را به همراه تعداد کل آنها نمایش دهد :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    [/TD]
    [TD="class: code"]Private Sub Command16_Click()

    Cls

    Dim i As Integer, b As Boolean, t As Integer, c As Integer

    For i = 10 To 99

    b = True

    t = i

    Do While t > 0 And b

    If t Mod 10 = 0 Then b = False

    t = t \ 10

    Loop

    If b Then

    c = c + 1

    Print i;

    If c Mod 20 = 0 Then Print

    End If

    Next

    MsgBox "Total: " & c

    End Sub

    [/TD]
    [/TR]
    [/TABLE]
     
  8. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    برنامه زیر یک عدد را خوانده، اول بودن آن را تعیین میکند و پیغام مناسبی چاپ میکند :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    [/TD]
    [TD="class: code"]Private Sub Command6_Click()

    Cls

    Dim i As Integer, n As Integer, t As Boolean

    n = InputBox("Enter a num:")

    t = True

    i = 2

    Do While i <= n / 2 And t

    If n Mod i = 0 Then t = False

    i = i + 1

    Loop

    If t Then

    Print "Prim"

    Else: Print "not prim"

    End If

    End sub

    [/TD]
    [/TR]
    [/TABLE]
     
  9. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    برنامه زیر یک عدد را گرفته و فاکتوریل آن را محاسبه و چاپ کند :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    [/TD]
    [TD="class: code"]Private Sub Command19_Click()

    Dim i As Integer, f&

    f = 1

    For i = 1 To InputBox("Enter a number to reach its single factorial:")

    f = f * i

    Next

    MsgBox f

    End Sub

    [/TD]
    [/TR]
    [/TABLE]
     
  10. hector2141

    hector2141 کاربر ارشد

    پاسخ : یه سری آموزش های فوق العاده جالب برای دوستان عزیز

    برنامه زیر اعداد 1 تا 10 مجموع اعداد از یک تا آن عدد را نمایش دهد :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    [/TD]
    [TD="class: code"]Private Sub Command20_Click()

    Cls

    Dim i As Integer, j As Integer, s As Integer

    For i = 1 To 10

    s = 0

    For j = 1 To i

    s = s + j

    Next

    Print s;

    Next

    End Sub

    [/TD]
    [/TR]
    [/TABLE]