روابط عمومي تاپيك آموزش مصور ويژال بيسيك

saalek110

Well-Known Member
روش خاموش كردن كامپيوتر در Vb

Amin_vb گفت:
با استفاده از اين كد مي‌توانيد كامپيوتر را خاموش نماييد.
ابتدا بايد كد زير را در يك ماژول وارد نماييد

Private Const EWX_SHUTDOWN As Long = 1
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long

سپس كد زير را وارد كنيد تا كامپيوتر خاموش شود.

lngResult = ExitWindowsEx(EWX_SHUTDOWN, 0&)
:idea: :idea: :idea: :idea: :idea: :idea: :idea:
:D :) :D :) :D
تشكر
 

saalek110

Well-Known Member
روش سريع ساخت آيكون از عكس

giahchin گفت:
با سلام،
يك روش براي ساخت آيكون بي دردسر و با كيفيت پيدا كردم كه خدمت دوستان عرض ميكنم.
فايل عكس مورد نظر را به فرمت ‌Bmp تغيير دهيد. (با فتوشاپ يا هر برنامه گرافيكي ديگه)
بعد پسوند فايل BMP را به ICO تغيير دهيد. (البته اين كار را فكر ميكنم بايد در محيط داس
انجام بديد چونكه ويندوز اين اجازه را به شما نميده)
حالا فايل شما يك آيكون شده است . البته هرموقه كه بخواهيد ميتونيد پسوند را به حال
اول برگردونيد و همون فايل BMP خودتون را داشته باشيد.

اميدوارم كه تكراري و كهنه نباشه و الا :oops:
هادي :wink:

ضمنا علت اينكه اين مطلب را در اين انجمن گذاشتم اين بود كه معمولا برنامه نويسها هستند كه
به دنبال تهيه يك آيكون خوشكل و راحت براي برنامشون مي گردند.
تشكر
 

saalek110

Well-Known Member
روش كار با clip board در VB

Amin_vb گفت:
با استفاده از اين كد شما مي‌توانيد يك عكس يا فايل متني را در كليپ بورد ذخيره نماييد يا اينكه تصوير يا متن ذخيره شده در كليپ بورد را در يك فايل ذخيره كنيد.

کد:
Public Function Load_Image_To_Clipboard(file As String)
Clipboard.SetData LoadPicture(file)
End Function

Public Function Save_Image_From_Clipboard(file As String)
SavePicture Clipboard.GetData, file
End Function

Public Function send_Text_File_To_Clipboard(file As String)
On Error GoTo error
Open file For Input As #1
Clipboard.SetText Input(LOF(1), 1)
Close #1
Exit Function
error:
y = MsgBox("File Not Found", vbOKOnly, "Error")
End Function

Public Function recive_Text_From_Clipboard_to(file As String)
On Error GoTo error
Open file For Output As #1
a$ = Clipboard.GetText
Print #1, a$
Close 1
Exit Function
error:
x = MsgBox("There has been a error!", vbOKOnly, "Error")
End Function
تشكر
 

saalek110

Well-Known Member
روش تعويض فرمت تاريخ كامپيوتر

Amin_vb گفت:
با اين كد شما مي‌توانيد فرمت تاريخ كامپيوتر خود را در ويژوال بيسيك عوض نماييد.

ابتدا كد زير را در يك ماژول وارد نماييد.
کد:
Public Const LOCALE_SSHORTDATE As Long = &H1F
Public Const LOCALE_USER_DEFAULT As Long = &H400

Public Declare Function GetLocaleInfo Lib "kernel32" _
    Alias "GetLocaleInfoA" (ByVal lLocale As Long, _
        ByVal lLocaleType As Long, ByVal sLCData As String, _
        ByVal lBufferLength As Long) As Long
Public Declare Function SetLocaleInfo Lib "kernel32" _
    Alias "SetLocaleInfoA" (ByVal Locale As Long, _
        ByVal LCType As Long, ByVal lpLCData As String) As Long

حال كد زير را در فرم برنامه خود وارد كنيد.

کد:
'put this code at form
'i have used for short date format similarly it can be used for long 
'date format

    Dim shortDateFormat As String
    Dim lBuffSize As String
    Dim sBuffer As String
    Dim lRetGet As Long
    Dim lRetSet As Long
    
    lBuffSize = 256
    sBuffer = String$(lBuffSize, vbNullChar)
    'get the date information in buffer
    lRetGet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, sBuffer, lBuffSize)
  
    If lRetGet > 0 Then
        shortDateFormat = Left$(sBuffer, lRetGet - 1)
        'this is the existing format of machine
   End If
    'to change the format if doesn't matches ur format
	'MM should be used in capital for monyhs,small m are for minutes
    If LCase(shortDateFormat) <> "dd/mm/yyyy" Then
        lRetSet = SetLocaleInfo(LOCALE_USER_DEFAULT,_ LOCALE_SSHORTDATE, "dd/MM/yyyy")
'on sucess lretset have value greater than 0
        If lRetSet <= 0 Then
             msgbox "date format not changed
        End If
    End If
تشكر
 

saalek110

Well-Known Member
فرستادن ايميل با vb

Amin_vb گفت:
بلاخره من يه كد كار كن برا فرستادن ايميل در vb پيدا كردم
اين كد از شي winsck استفاده مي كند و شما بايد يك شي از اين نوع با نام winsck1 روي فرم برنامه خود قرار دهيد سپس شما مي‌توانيد با استفاده از تابع SendEmail ايميل خود را ارسال نماييد
موفق باشيد
:lol: :lol: :lol:


کد:
Dim Response As String, Reply As Integer, DateNow As String
Dim first As String, Second As String, Third As String
Dim Fourth As String, Fifth As String, Sixth As String
Dim Seventh As String, Eighth As String
Dim Start As Single, Tmr As Single

Sub SendEmail(MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String)
          
    Winsock1.LocalPort = 0 ' Must set local port to 0 (Zero) or you can only send 1 e-mail pre program start
    
If Winsock1.State = sckClosed Then ' Check to see if socet is closed
    DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
    first = "mail from:" + Chr(32) + FromEmailAddress + vbCrLf ' Get who's sending E-Mail address
    Second = "rcpt to:" + Chr(32) + ToEmailAddress + vbCrLf ' Get who mail is going to
    Third = "Date:" + Chr(32) + DateNow + vbCrLf ' Date when being sent
    Fourth = "From:" + Chr(32) + FromName + vbCrLf ' Who's Sending
    Fifth = "To:" + Chr(32) + ToNametxt + vbCrLf ' Who it going to
    Sixth = "Subject:" + Chr(32) + EmailSubject + vbCrLf ' Subject of E-Mail
    Seventh = EmailBodyOfMessage + vbCrLf ' E-mail message body
    Ninth = "mouse mailer" + vbCrLf ' What program sent the e-mail, customize this
    Eighth = Fourth + Third + Ninth + Fifth + Sixth  ' Combine for proper SMTP sending

    Winsock1.Protocol = sckTCPProtocol ' Set protocol for sending
    Winsock1.RemoteHost = MailServerName ' Set the server address
    Winsock1.RemotePort = 25 ' Set the SMTP Port
    Winsock1.Connect ' Start connection
    
    WaitFor ("220")
    
    StatusTxt.Caption = "Connecting...."
    StatusTxt.Refresh
    
    Winsock1.SendData ("HELO worldcomputers.com" + vbCrLf)

    WaitFor ("250")

    StatusTxt.Caption = "Connected"
    StatusTxt.Refresh

    Winsock1.SendData (first)

    StatusTxt.Caption = "Sending Message"
    StatusTxt.Refresh

    WaitFor ("250")

    Winsock1.SendData (Second)

    WaitFor ("250")

    Winsock1.SendData ("data" + vbCrLf)
    
    WaitFor ("354")


    Winsock1.SendData (Eighth + vbCrLf)
    Winsock1.SendData (Seventh + vbCrLf)
    Winsock1.SendData ("." + vbCrLf)

    WaitFor ("250")

    Winsock1.SendData ("quit" + vbCrLf)
    
    StatusTxt.Caption = "Disconnecting"
    StatusTxt.Refresh

    WaitFor ("221")

    Winsock1.Close
Else
    MsgBox (Str(Winsock1.State))
End If
   
End Sub
Sub WaitFor(ResponseCode As String)
    Start = Timer ' Time event so won't get stuck in loop
    While Len(Response) = 0
        Tmr = Start - Timer
        DoEvents ' Let System keep checking for incoming response **IMPORTANT**
        If Tmr > 50 Then ' Time in seconds to wait
            MsgBox "SMTP service error, timed out while waiting for response", 64, MsgTitle
            Exit Sub
        End If
    Wend
    While Left(Response, 3) <> ResponseCode
        DoEvents
        If Tmr > 50 Then
            MsgBox "SMTP service error, impromper response code. Code should have been: " + ResponseCode + " Code recieved: " + Response, 64, MsgTitle
            Exit Sub
        End If
    Wend
Response = "" ' Sent response code to blank **IMPORTANT**
End Sub


Private Sub Command1_Click()
    SendEmail txtEmailServer.Text, txtFromName.Text, txtFromEmailAddress.Text, txtToEmailAddress.Text, txtToEmailAddress.Text, txtEmailSubject.Text, txtEmailBodyOfMessage.Text
    'MsgBox ("Mail Sent")
    StatusTxt.Caption = "Mail Sent"
    StatusTxt.Refresh
    Beep
    
    Close
End Sub

Private Sub Command2_Click()
    
    End
    
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    Winsock1.GetData Response ' Check for incoming response *IMPORTANT*

End Sub
تشكر
 

saalek110

Well-Known Member
فهميدن دايركتوري ويندوز در vb

Amin_vb گفت:
بازم سلام
ويژگي خاص اين كد اين است كه فقط با يك خط دستور و بدون استفاده از API مي‌توان دايركتوري ويندوز را بدست آورد
:lol: :lol:
کد:
Dim WindowsDir as String
WindowsDir = environ("windir")
.
Amin_vb گفت:
شما مي‌توانيد با كد زير دايركتوري ويندوز را بفهميد كجاست

کد:
Dim Windows 

Windows = Environ("Windir")
'Get the Windows directory from a MS-Dos Environment, stored in c:\msdos.sys


MsgBox Windows
.
giahchin گفت:
سلام دوست عزيز،
البته براي اين كار ميشه از API هم كمك گرفت .
اينطوري
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Dim StrFolder As String * 255
Dim IntLength As Integer
IntLength = GetWindowsDirectory(StrFolder, 255)

MsgBox Left(StrFolder, IntLength)


هادي :wink:
.
mahdi22m گفت:
سلام به دوستان
در مورد اين روشها به نظر من روش آقا امين بهينه تره چون نياز به فراخواني توابع سيستمي نداره چون از متغيير هاي محيطي سيستم عامل ويندوز استفاده مي كنه كه در ابتداي فرآيند بالا آمدن ويندوز مقدار دهي مي شوند. اين متغيير ها در سطح بسيار زيادي قابل استفاده هستند حتي در محيط خود ويندوز و اكسپلورر. البته به جاي WinDir ميشه از SystemRoot هم استفاده كرد. مثلا در منوي Run ويندوز خودتون اي اين قابليت براي رسيدن سريع به پوشه فونت ويندوز خودتون مي تونيد استفاده كنيد:
systemroot%\fonts%


تشكر
 
آخرین ویرایش:

saalek110

Well-Known Member
ساختن فايل zip در ويژوال بيسيك

saman_sweden گفت:
سلام آقا براي اينكه برنامه نويسي كلا يسري مشكلات داره من شخصا سعي نمي كنم پاسخ بدم
اما شما بايد از اين كد براي zip يا unzip استفاده كنيد


کد:
'     devloped by Saman_sweden

Function winZipit(ByVal source As String, ByVal target As String, ByVal zip As Boolean)
    zipIT = App.Path & "winzip32 -a"
    unzipIT = App.Path & "winzip32 -e "


    If zip = True Then
        Shell (zipIT & target & source)
    Else: Shell (unzipIT & target & source)
    End If
End Function

قبلا تست شده
تشكر
 

saalek110

Well-Known Member
دسترسي به ساير برنامه‌هاي در حال

ali_aaa گفت:
سلام
چطوري ميشه در vbبه ساير برنامه‌هايي كه در حال اجرا هستند دسترسي پيدا كرد
مثلا اگه ماشين حساب ويندوز در حال اجرا است به آن دسترسي پيدا كرد و بدون كار با خود برنامه يك عدد را در TextBox آن وارد كرد.
.
mahdi22m گفت:
سلام
اين مورد رو يك بار ديگه هم گفته بودم. ببينيد هر ويندو در سيستم عامل ويندوز يك هندل داره به همين ترتيب هر كنترل نيز اين چنين است. شما مي تونيد با داشتن هندل كنترل به توابع آن دسترسي داشته باشيد. حتي رنگ متن يا محتوي يك اديت باكس رو عوض كنيد.
موفق باشيد
تشكر
 

saalek110

Well-Known Member
استفاده از directX در vb 6 !!!!

omidak گفت:
سلام:
1 مثال ساده كه File Building.x رو اجرا میکنه :wink:
و در BackGround فایل BackGround.bmp رو قرار میده :wink:
کد:
'General Declarations
Dim pos As D3DVECTOR
'These three components are the big daddy of what your 3D Program.
Dim DX_Main As New DirectX7 ' The DirectX core file (The heart of it all)
Dim DD_Main As DirectDraw4 ' The DirectDraw Object
Dim D3D_Main As Direct3DRM3 ' The direct3D Object

'DirectInput Components
Dim DI_Main As DirectInput ' The DirectInput core
Dim DI_Device As DirectInputDevice ' The DirectInput device
Dim DI_State As DIKEYBOARDSTATE 'Array Holding the state of the keys

'DirectDraw Surfaces- Where the screen is drawn.
Dim DS_Front As DirectDrawSurface4 ' The frontbuffer (What you see on the screen)
Dim DS_Back As DirectDrawSurface4 ' The backbuffer, (Where everything is drawn before it's put on the screen.)
Dim SD_Front As DDSURFACEDESC2 ' The SurfaceDescription
Dim DD_Back As DDSCAPS2 ' General Surface Info

'ViewPort and Direct3D Device
Dim D3D_Device As Direct3DRMDevice3 'The Main Direct3D Retained Mode Device
Dim D3D_ViewPort As Direct3DRMViewport2 'The Direct3D Retained Mode Viewport (Kinda the camera)

'The Frames
Dim FR_Root As Direct3DRMFrame3 'The Main Frame (The other frames are put under this one (Like a tree))
Dim FR_Camera As Direct3DRMFrame3 'Another frame, just happens to be called 'camera'. We will use this
                                                   'as the viewport. Hence, the name camera. Doesn't have to be
                                                   'called 'camera'. It could be called 'BillyBob' for all I care.
Dim FR_Light As Direct3DRMFrame3 'This frame contains our, guess what, spotlight!
Dim FR_Building As Direct3DRMFrame3 'Frame containing our 1st mesh that will be put in this "game".

'Meshes (3D objects loaded from a .x file)
Dim MS_Building As Direct3DRMMeshBuilder3

'Lights
Dim LT_Ambient As Direct3DRMLight 'Our Main (Ambient) light that illuminates everything (not just part of something
                                                'like a spotlight.
Dim LT_Spot As Direct3DRMLight 'Our Spot light, makes it look more realistic.

'Camera Positions
Dim xx As Long
Dim yy As Long
Dim zz As Long

Dim esc As Boolean 'If Escape is pressed, the DX_Input sub will make it true and the main loop will end.
'Incase you haven't caught on, the prefix FR = frame, MS = Mesh, & LT = light.

Dim BackGround As Direct3DRMTexture3 'This will be the texture that holds our background.
'Note: Texture files must have side lengths that are devisible by 2!
'======================================================================================

Private Sub DX_Init()
 'Type, not copy and paste!
 'This sub will initialize all your components and set them up.
 Set DD_Main = DX_Main.DirectDraw4Create("") 'Create the DirectDraw Object

 DD_Main.SetCooperativeLevel Form1.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE 'Set Screen Mode (Full 'Screen)
 DD_Main.SetDisplayMode 640, 480, 32, 0, DDSDM_DEFAULT 'Set Resolution and BitDepth (Lets use 32-bit color)
 
 SD_Front.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
 SD_Front.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_3DDEVICE Or DDSCAPS_COMPLEX Or _
 DDSCAPS_FLIP 'I used the line-continuation ( _ ) because the whole thing wouldn't fit on one line...
 SD_Front.lBackBufferCount = 1 'Make one backbuffer
 Set DS_Front = DD_Main.CreateSurface(SD_Front) 'Initialize the front buffer (the screen)
 'The Previous block of code just created the screen and the backbuffer.
 
 DD_Back.lCaps = DDSCAPS_BACKBUFFER
 
 Set DS_Back = DS_Front.GetAttachedSurface(DD_Back)
 DS_Back.SetForeColor RGB(255, 255, 255)
 'The backbuffer was initialized and the DirectDraw text color was set to white.

 Set D3D_Main = DX_Main.Direct3DRMCreate() 'Creates the Direct3D Retained Mode Object!!!!!

 Set D3D_Device = D3D_Main.CreateDeviceFromSurface("IID_IDirect3DHALDevice", DD_Main, DS_Back, _
 D3DRMDEVICE_DEFAULT) 'Tell the Direct3D Device that we are using hardware rendering (HALDevice) instead
                                   'of software enumeration (RGBDevice).
 D3D_Device.SetBufferCount 2 'Set the number of buffers
 D3D_Device.SetQuality D3DRMRENDER_GOURAUD 'Set Rendering Quality. Can use Flat, or WireFrame, but
                                                                  'GOURAUD has the best rendering quality.
 D3D_Device.SetTextureQuality D3DRMTEXTURE_NEAREST 'Set the texture quality
 D3D_Device.SetRenderMode D3DRMRENDERMODE_BLENDEDTRANSPARENCY 'Set the render mode.

 Set DI_Main = DX_Main.DirectInputCreate() 'Create the DirectInput Device
 Set DI_Device = DI_Main.CreateDevice("GUID_SysKeyboard") 'Set it to use the keyboard.
 DI_Device.SetCommonDataFormat DIFORMAT_KEYBOARD 'Set the data format to the keyboard format.
 DI_Device.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE 'Set Coperative Level.
 DI_Device.Acquire
 'The above block of code configures the DirectInput Device and starts it.
End Sub

'=====================================================================================

Private Sub DX_MakeObjects()
 Set FR_Root = D3D_Main.CreateFrame(Nothing) 'This will be the root frame of the 'tree'
 Set FR_Camera = D3D_Main.CreateFrame(FR_Root) 'Our Camera's Sub Frame. It goes under FR_Root in the 'Tree'.
 Set FR_Light = D3D_Main.CreateFrame(FR_Root) 'Our Light's Sub Frame
 Set FR_Building = D3D_Main.CreateFrame(FR_Root) 'Our Building (the 3D Thingy that will be placed in our world's)
                                                                      ' sub frame.
 'That above code set up the hierarchy of frames where FR_Root is the parent, and the other frames are all
 'owned by it.
 
 FR_Root.SetSceneBackgroundRGB 0, 0, 1 'Set the background color. Use decimals, not the standerd 255 = max.
                                                         'What I have here will make the background/sky 100% blue.
 FR_Camera.SetPosition Nothing, 1, 4, -35 'Set The Camera position; X=1, Y=1, z=0.
 Set D3D_ViewPort = D3D_Main.CreateViewport(D3D_Device, FR_Camera, 0, 0, 640, 480) 'Make our viewport and set
                                                                                                                  'it our camera to be it.
 D3D_ViewPort.SetBack 200 'How far back it will draw the image. (Kinda like a visibility limit)
  
 FR_Light.SetPosition Nothing, 1, 6, -20 'Set our 'point' light.
 Set LT_Spot = D3D_Main.CreateLightRGB(D3DRMLIGHT_POINT, 1, 1, 1) 'Set the light type and it's color.
 FR_Light.AddLight LT_Spot 'Add the light to it's frame.
  
 Set LT_Ambient = D3D_Main.CreateLightRGB(D3DRMLIGHT_AMBIENT, 0.5, 0.5, 0.5) 'Create our ambient light.
 FR_Root.AddLight LT_Ambient 'Add the ambient light to the root frame.
 
 Set BackGround = D3D_Main.LoadTexture(App.Path & "\background.bmp") 'Load our background texture and put it into BackGround
 FR_Root.SetSceneBackgroundImage BackGround 'Take our texture and make it the scene's background.
 
 Set MS_Building = D3D_Main.CreateMeshBuilder() 'Make the 3D Building Mesh
 MS_Building.LoadFromFile App.Path & "\building.x", 0, 0, Nothing, Nothing 'Load our building mesh from its .X file.
 MS_Building.ScaleMesh 0.5, 0.5, 0.5 'Set the it's scale. This is used to make the object smaller or bigger. 1 makes
                                          'it the same size as it was built in whatever program it was built in. .5 is half as big
 FR_Building.AddVisual MS_Building 'Add the 3D Building mesh to it's frame.

End Sub

'=====================================================================================

Private Sub DX_Render()
 'Lets put our main loop. Make it loop until esc = true (I'll explain later)
 Do While esc = False
   On Local Error Resume Next 'Incase there is an error
   DoEvents 'Give the computer time to do what it needs to do.
   DX_Input 'Call the input sub.
   FR_Camera.GetPosition Nothing, pos
   D3D_ViewPort.Clear D3DRMCLEAR_TARGET Or D3DRMCLEAR_ZBUFFER 'Clear your viewport.
   D3D_Device.Update 'Update the Direct3D Device.
   D3D_ViewPort.Render FR_Root 'Render the 3D Objects (lights, and your building!)
   DS_Back.DrawText 200, 0, "Direct3D Example X: " & pos.x & " Z: " & pos.z, False  'Draw some text!
   DS_Front.Flip Nothing, DDFLIP_WAIT 'Flip the back buffer with the front buffer.
 Loop
End Sub

'=====================================================================================

Private Sub DX_Input()
    Const Sin5 = 8.715574E-02!  ' Sin(5°)
    Const Cos5 = 0.9961947!     ' Cos(5°)
 DI_Device.GetDeviceStateKeyboard DI_State 'Get the array of keyboard keys and their current states
  
 If DI_State.Key(DIK_ESCAPE) <> 0 Then Call DX_Exit 'If user presses [esc] then exit end the program.
 
 If DI_State.Key(DIK_LEFT) <> 0 Then 'Quick Note: <> means 'does not'
   'FR_Camera.SetPosition FR_Camera, -1, 0, 0 'Move the viewport to the left
   FR_Camera.SetOrientation FR_Camera, -Sin5, 0, Cos5, 0, 1, 0
 End If
 
 If DI_State.Key(DIK_RIGHT) <> 0 Then
   'FR_Camera.SetPosition FR_Camera, 1, 0, 0 'Move the viewport to the right
   FR_Camera.SetOrientation FR_Camera, Sin5, 0, Cos5, 0, 1, 0
 End If
 
 If DI_State.Key(DIK_UP) <> 0 Then
   FR_Camera.SetPosition FR_Camera, 0, 0, 1 'Move the viewport forward
 End If

 If DI_State.Key(DIK_DOWN) <> 0 Then
   FR_Camera.SetPosition FR_Camera, 0, 0, -1 'Move the viewport back
 End If

End Sub

'=====================================================================================

Private Sub DX_Exit()
 Call DD_Main.RestoreDisplayMode
 Call DD_Main.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL)
  Call DI_Device.Unacquire
 'Restore all the devices

 End 'Ends the program.
End Sub

'=====================================================================================

Private Sub Form_Load()
 Me.Show 'Some computers do weird stuff if you don't show the form.
 DoEvents 'Give the computer time to do what it needs to do
 DX_Init 'Initialize DirectX
 DX_MakeObjects 'Make frames, lights, and mesh(es)
 DX_Render 'The Main Loop

End Sub
تشكر
 

saalek110

Well-Known Member
كپي فولدر و محتوا توسط Vb6 ؟

giahchin گفت:
با سلام،
من مي خوام در Visual Basic 6 يك فولدر با تمام محتوياتش را در يك مسير
ديگه كپي كنم ولي در Help ويژوال بيسيك فقط دستورات ساده كپي را
پيدا كردم كه تنها يك فايل را ميتونه كپي كنه ولي دستوري براي كپي يك فولدر
با تمام فايلها و ساب فولدرهاي داخل آن پيدا نكردم.
لطفا اگه كسي مي تونه من رو راهنمايي كنه.

sign1.jpg
.
parshia گفت:
salam fek konam in bedardet bekhoreh
Syntax


[
object.CopyFolder source, destination [, overwrite

VA PART HAYE DIGASH INEH
KEH MANZOURE (FileSystemObject) <-------object
source
destination
KEH MANZOURE (Boolean )< -------overwrite

INAM YE MESAL:
FileSystemObject . CopyFolder
c:\mydocuments\letters
,"*\
"\c:\tempfolder"
.
ادامه بحث در تاپيكي با نام همين پست صفحه 27
.
 

saalek110

Well-Known Member
دستور Search در ويژوال بيسيك6

777 گفت:
سلام
من يك برنامه جستجو با ويژوال بيسيك6 نياز دارم.دوستاني كه به اين موضوع احاطه دارند لطفاْ مرا راهنمايي نمايند.سپاسگذارم.
.
masoud_kia_kia گفت:
راستش من جستجوي متن كدشو مينيويسم
کد:
Private Sub cmdSearch_Click()
Dim txt1 As String, txt2 As String
Dim firstS As Integer, lastS As Integer

txt1 = txtinput1.Text
txt2 = txtinput2.Text

firstS = InStr(txt1, txt2)
If firstS <> 0 Then
lbldisplay1.Caption = " Forward Search The text was found ast position " & firstS
Else
lbldisplay1.Caption = " Forward Search The text was Not found"
End If

lastS = InStrRev(txt1, txt2)
If lastS <> 0 Then
lbldisplay2.Caption = " Backward Search The text was found ast position " & lastS
Else
lbldisplay2.Caption = " Backward Search The text was Not found"
End If

End Sub

اگر مفهوم نبود به من ميل بزن
[email protected]
براي عدد كه جستجوي خطي است
کد:
Function linearsearch(a() As Integer, key As Integer) As Integer
Dim x As Integer
 For x = LBound(a) To UBound(a)
 If a(x) = key Then
 linearsearch = x
 Exit Function
 End If
Next x
linearsearch = -1
 
End Function
تشكر
 

saalek110

Well-Known Member
فارسي نوشتن در وي بي

navidal گفت:
دوستان من چطور ميتونم در برنامه اي كه در وي بي نوشتم از فونت فارسي استفاده كنم طور ي كه روي كامپيوتر ديگري بردم با مشكل مواجه نشوم يعني هم فارسي بنويسم و هم فارسي از كاربر بگيرم در ضمن از ويندوز ايكس پي استفاده ميكنم .

اگه راهنمايي كنيد ممنون ميشم.
.
a_mollaei گفت:
با سلام.

شما دو كار مي تونيد انجام بديد.
يا از سيستم فارسي پيش فرض ويندوز استفاده كنيد كه در اين صورت كافيه زابن فارسي را به كي بردتون اضافه كنيد و كار رو شرع كنيد.
البته كاربرتون هم بايد سيستمش فارسي باشه. و دو كاربر با دو ويندوز مختلف مثلا يكي 98 و ديگري Xp نمي توانند از سيستم شما به صورت هم زمان استفاده كنن چون توي حروف (ح و د و ي) به مشكل مي خورند.

راه حل ديگه اينكه يك ActiveX طراحي كنيد كه كار تبديل زبان كي برد رو انجام بده. دقيقا مثل چيزي كه در اينترنت استفتده مي شه . البته شما بايد تمام موارد رو در نظر بگيريد يعني با زدن Space حرف كوچك به حرف بزرگ تبديل بشه و بعد از حروفي مثل (د) حرف چسبيده نباشه و خيلي مشكلات ديگه كه در برنامه نويسي وب وجود نداره. مثلا آقا مجيد براي اين textarea كه پايين صفحه هست فقط تعويض حروف رو انجام داده ولي شما بايد كاملا تمام مسايل رو به حساب بياري (اونايي كه بالا گفتم) در صورتي كه بخواي از activex استفاده كني بايد با يه فونت true type كار كني كه توي تموم ويندوز ها جواب بده.

من توصيه مي كنم از راه اول استفاده كن يا از activex هاي آماده كه توي تموم CD ها هست.
.
saman_sweden گفت:
شما اگر اون برنامه اي مي نويسي انيستال پكيج كني ميتوني تو هر كامپيوتري استفاده كني براي اينكه توي ويندوز ايكس پي اون برنامه وورد يا هرچه كه ساخته اي با يونيكد است تو هر ماشيني كه ويندوز ايكس پي داري مشكل موقع اينستال نحواهي داشت اما اگر غير از پلات فرم ويندوز ايكس پي باشد دردسر داره نمي توني استفاده بكني
تشكر
 

saalek110

Well-Known Member
چه طوري ميشه اطلاعات رو در ويژوال بيسيك روي فايل ذخيره كرد

NextWorld IT گفت:
سلام شما با هر پسوندي ميتونيد كه يك فايل بسازيد و بعد در اون داده ذخيره كنيد و سپس داده هاي خود را فراخوانيد
بايد از فرمان open استفاده كنيد و بعد اگر خواستيد فقط فايل را بخوانيد از INPUT در اخر عبارت استفاده ميكنيد و براي نوشتن و يا ويرايش فايل از OUTPUT استفاده خواهيد كرد. مثال زير روشن تر است:

کد:
Open  "myFile.txt" For Output As #1
     Print #1, "name", "surename", )
     Print #1, "hamed", "hamedi", )
     Print #1, "Reza", "James", )
Close #1

و حال براي خواندن نيز از:

کد:
Open   "myFile.txt" For Input As #1

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

saalek110

Well-Known Member
راست كليك در ويژوال بيسيك

Payam Moradi گفت:
در وي بي كه بلد هستيد منوهاي بالاي فرم رو ايجاد كنيد. حالا منوي اصلي Visible رو False قرار بده. حالا كافيه با كد ذيل منويي كه Visible اونو منفي كردي فراخواني كنيد.
در اين كد با راست كليك بروي فرم منو ظاهر ميشه :

کد:
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbRightButton Then
      PopupMenu Main_Menu_Name
     End If
End Sub

اين كد رو دقيقا در ماژول فرم قرار بدهيد. و به جاي Main_Menu_Name نام منوي اصلي رو قرار بدهيد.
برنامش هم فرستادم. :wink:
تشكر
 

saalek110

Well-Known Member
On Top در ويژوال بيسيك

Anti-Opensource گفت:
سلام ..كدي رو سراغ داريد كه پنجره ي فرم رو On top كنه كه زير پنجره ها ي ديگه نره؟
ممنون
.
saman_sweden2 گفت:
در اين موارد بهتره از help خود وي بي استفاده كنيد


اين كدش البته ميشه بصورتهاي گوناگون نوشت


کد:
Private Sub mnustayontop_Click()

Dim rtn

If mnustayontop.Checked = False Then
   rtn = SetWindowPos(OnTop.hwnd, -1, 0, 0, 0, 0, 3)
   mnustayontop.Checked = False
Else
   rtn = SetWindowPos(OnTop.hwnd, -2, 0, 0, 0, 0, 3)
   mnustayontop.Checked = True
End If

End Sub

اينم بايد توي باس باشه
کد:
Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
تشكر
 

saalek110

Well-Known Member
ساخت HotKey جهت برنامه‌هاي VB

Amin_vb گفت:
شما مي‌توانيد جهت برنامه ويژوال بيسيك خود يك كليد دسترسي درست كنيد كه مثلا هر موقع زده شود برنامه شما باز شود.

شما بايد كد زير را در Form_Load قرار دهيد.
با اين كد ابتدا فرم برنامه Minimze مي‌شود.
در اين كد كليد دسترسي Alt+Z است و با زده شدن آن فرم برنامه باز مي‌شود.

اين قسمت بايد در يك ماژول باشد
کد:
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long  
Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long  
Public Const WM_SETHOTKEY = &H32
Public Const WM_SHOWWINDOW = &H18
Public Const HK_SHIFTA = &H141 'Shift + A
Public Const HK_SHIFTB = &H142 'Shift * B
Public Const HK_CONTROLA = &H241 'Control + A
Public Const HK_ALTZ = &H45A

اين قسمت را بايد در Form_Load قرار داد.
کد:
'put this code in the Form_Load event of a form
Dim lngReturn As Long

'minimize window
Me.WindowState = vbMinimized
'select the hotkey for your app, ALT-Z in this case
lngReturn = SendMessage(Me.hwnd, WM_SETHOTKEY, HK_ALTZ, 0)
'Check if succesfull
If lngReturn <> 1 Then
    MsgBox "Select another hotkey"
End If
'Tell windows what to do when hotkey is selected
lngReturn = DefWindowProc(Me.hwnd, WM_SHOWWINDOW, 0, 0)
تشكر
 

saalek110

Well-Known Member
روش ساخته متنهاي سه‌بعدي در Vb

Amin_vb گفت:
با استفاده از اين كد شما مي‌توانيد متنهاي خود را به صورت سه‌بعدي در ويژوال بيسيك نمايش دهيد.

كافيست كد زير ار اجرا نماييد و به جاي YOUR TEXT HERE متن خود را قرار دهيد.

کد:
' Add It To a ButtoN !
ForeColor = 0: x = CurrentX: y = CurrentY
For i = 1 To 100
        Print "YOUR TEXT HERE" ' Text Here
        x = x + 1: y = y + 1: CurrentX = x: CurrentY = y
Next
ForeColor = &HFFFF& 'Change Color Here
Print "YOUR TEXT HERE" ' Text Goes Here
تشكر
.
 

saalek110

Well-Known Member
س : چجوري ميشه دكمه Button هايي رو كه تو فتوشاپ ساختم رو تو Visual آورد ؟

Mikhak گفت:
عزيزه من شما ميخواي يه دكمه رو تو فتو شاپ طراحي كني بعدش بياري توي visual استفاده كني اگه درست فهميده باشم
خوب شما ميتوني به صورت يه image توي visual يه دكمه رو بسازي ميتوني براي كليدت حالت هاي over يا down يا هرچيزه ديگه كه خواستي تعريف كني
--------------
سينا
تشكر
 

saalek110

Well-Known Member
درود

Doste گفت:
با سلام.

سالک جان واقعا خوب پیش رفتی .

جای تحسین داره :wink:

اگه مشکلی و یا به چیزی نیاز داشتی بهم بگو (البته تو پیغام خصوصی).

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

جدیدترین ارسال ها

بالا