Basics of programming.
Programming language Small Basic
LESSON 1: Introduction to the programming environment Small Basic .
Target: introduce with the Small Basic programming language.
Tasks:
Start learning a programming language Small Basic. Give the concept of OOP (object-oriented programming)
Learn to work in this programming environment. P familiarize with the "text object" of the environment Small Basic.
To give a first idea of creating programs in a programming environment.
The main educational tasks of the project:
Upbringing personal qualities: purposefulness, attentiveness, accuracy, objectivity in self-assessment, responsibility, cognitive interest.
The main development tasks of the project:
To form in students key competencies that contribute to successful social adaptation;
To develop the desire for self-development and personal growth through cognitive activity.
Know: Basic concepts: object, variables, assignment, data types, input-output.Know the constituent elements of the Small Basic programming environment.
Be able to: Download the Smal Basic program. Create simple projects in this programming environment. Be able to enter mathematical functions and write mathematical expressions in the Smal Basic language. Write simple linear programs.
Equipment and material: basic lecture notes (cf.Attachment 1 ), task cards, PC, Small Basic application, whiteboard, multimedia projector, screen.
During the classes:
Preparing for the lesson
Knowledge update
Related questions
Grading
Homework
Organizing time
Explanation of new material
Consolidation of the studied material
Summarizing
Preparing for the lesson (check readiness for the lesson, mark absent)
Knowledge update
Organizing time
What is programming for?
You want to write an abstract in biology. Most likely, you will write it on a computer in some text editor. And where did it come from text editor? Of course, programmers wrote it. You will search for information on the Internet using a browser that programmers also wrote. After you write your essay, you will want to relax and play computer game, which again was written by programmers. In general, working on a computer is impossible without the use of programs that programmers write. This means that if there was no programming, there would be no programs, and the computer would be a bunch of expensive hardware, because it is impossible to do something with the help of a computer without programs.
Stages of problem solving.
Basic concepts
Programming - writing programs.
Program An algorithm written in a programming language understandable by a computer.
Algorithm - a clear sequence of actions aimed at achieving the goal.
In object-oriented programming the concept of an object is introduced, calculation mechanisms are implemented that allow:
Describe the structure of an object
Describe actions with objects
Use special object inheritance rules (Inheritance means creating new objects from existing ones)
Set the degree of protection of object components
Theory
First meeting
Microsoft Small Basic - programming language developed by . Designed for novice developers who want to learn the basics of creating programs.
Main advantages:
A very simple development environment - a text editor with a multifunctional tooltip and only a few buttons for editing text and launching programs.
Simple language with only 20 keywords
Contextual documentation built into the development environment for all elements of the language
Ability to extend Small Basic components to include additional functionality. (For example, the delivery already includes features for working with services)
A special advantage of BASIC should be considered the ability to work in interpretation mode, which greatly simplifies the process of debugging programs: the execution of almost every command can be checked immediately after writing.
Output operator
WriteLine("Hi!")Displays a string (text or number )
Hello!
To get the result - the output of the text "Hello!" on the screen - you need to write a program:
TextWindow.WriteLine("Hi!")
The program is entered into the windowsmallBasicand start with a buttonlaunch or key F 5
The result of the program is the output of the text: "Hello!" intext box programs.
The string means "Press any key to continue…."
TextWindow is a "text window" object in which text can be displayed.
The object has properties and methods.
Object method -what the object can do, i.e. itoperations (operators )
Parameter operations are enclosed in WriteLine brackets()
Same object text box has properties (these are the characteristics of the object) , for example
BackgroundColor property – sets the background color for the text,ForegroundColor- text color
Colors:
redyellow
green
blue
black
white
red
yellow
green
blue
the black
white
Variable
Variables are often used to create programs.
variable hasname - latin letter (a)
A variable can be assigned a value, such as a number
a= 5, where the sign " = " - this is assignment operator
string valuea = a + 5
Take the value of variable a
Add 5 to it
Set a new value to the variable a, deleting the previous one from it
The variable is of two types: number and line
10, -5, 3.14 "computer science"
Fold +Multiply *
Divide /
Math actions:
Sine, logarithm, root
glue
Divide into parts
Search symbols
Replace characters
EXAMPLE with operator "+"
expression
result
expression
result
"ivan" + "ova"
"ivanova"
"class" + 10
"class 10"
Programming
Example 1: program result
Example 2: program result
Example 3: The program calculates and displays the sum of two variablesa and b
Math.Abs(number)
module
Math.Cos( number)
cosine
Math Ceiling(number)
rounds up to a whole number
Math.GetDegrees( number)
converting a number from radians to degrees
Math.GetRandomNumber( maxnumber)
Random number in the range from 1 tomaxnumber
NaturalLog(number)
natural logarithm
Math Pi
Pi
Math.Power( baseNumber, exponent)
AT oraising baseNamber to the power of exponent
Math. max(number1,number2)
Maximum of two numbers
Math. Remainder(dividend, divisor)
Remainder of the division
Math .Sin(number)
Sinus
Math. Tan(number)
Cosine
Math .ScuareRoot(number)
Root
Math. Round(number)
Normal rounding
Math .ArcSin(number)
Arcsine
Math. floor(number)
Rounds down to the nearest smallest integer
x=TextWindow.ReadNumber()
y=Math.Abs(x)
TextWindow.WriteLine("y equals "+y)
Math PiFixing the material
Independent practical work for PC
Tasks for independent work
Exercise 1:
Define end results of assignment statements
X=3Y=2
X=X+2
Y=X*2
X=Y
A= 15
B=A
A=B/5+2
B=A*3
A=0
Task 2 : Write a program for calculating the product of 3 variables:a , b and c .
Task 3 : Write a program for calculating the expression:z=5* x+ y/2 (assuming x=10,y=100)
Task 4: Write a program to output the values of X andY, according to task 1.
Task 5: Write a program to find the discriminant
Task 6 : evaluate expressions
(5+5) 3 (1000 )
2+|3-25| (24 )
4 2 – (10)
Cos 2 (Pi/4)+ Sin 2 (Pi/2) (1 )
( 1)
Y=2x 2 ( at x=5, y=50)
X 1,2 \u003d (when a \u003d 2, b=6, c=4 , x 1=-1, x 2=-2)
Z= ln(y)-3 ( at y=3, z=-1.901…)
С= (when a=4, b=9, c=13)
Y=cos(x)+sin(x) (x=180 0 ,y=-1)
Questions
What is a program?
What are programming languages for?
What are the basic elements of object-oriented programming?
What operations can be performed in the "text window"?
What does the assignment operator mean:
What types of data are used in Small Basic?
How are I/O statements written?
Grading
Homework
Summarizing
Work with a summary
prepare a message on the topic: "A variety of programming languages"
Make a program calculating the area of a triangle using Heron's formula
Application
OK 1: Fundamentals of programming in the language Small Basic .
Programming - writing programs.
ALGORITHM + PROGRAMMING LANGUAGE= PROGRAM
Variable
variable hasname - Latin letter (For example,a , AT , x1 , C9 )
A variable can be assigned a value
Example: a = 5 , where the sign " = " - this is assignment operator
The variable is of two types: number and line (character sequence)
10, -5, 3.14 "computer science"
Fold +Multiply *
Divide /
Math actions:
Sine, logarithm, root
glue
Divide into parts
Search symbols
Replace characters
Programming
TextWindow- this is object "window with text" , in which text can be displayed.
Operation parameter enclosed in brackets - WriteLine()
An object text box has properties , for example
Property background color - sets the background color for the text,ForegroundColor - text color
Used colors:
redyellow
green
blue
black
white
red
yellow
green
blue
the black
white
Small Basic Operators
"+" operator
Main OperatorsUsing math functions in an expression
Writing complex mathematical expressions Math Pi TextWindow.WriteLine("Enter the value of variable x")x=TextWindow.ReadNumber()
y=Math.Abs(x)
TextWindow.WriteLine("y equals "+y)
TextWindow.WriteLine(Math.Abs(-10))
Program for calculating the sum of two variablesa and b
TextWindow.WriteLine("Enter the value of variable a")
a=TextWindow.ReadNumber()
TextWindow.WriteLine("Enter the value of variable b")
b=TextWindow.ReadNumber()
s=a+b
TextWindow.WriteLine(" the sum of the numbers is "+s)
The program is entered into the windowsmallBasicand start with a buttonlaunch or key F 5.
Line Press any key continue ...means " Press any key to continue
Hello everyone, in this article I want to show you useful codes small programs. Which you can use to write your own more serious programs, or you were looking for exactly these functions that are described here.
All codes were used in the Microsoft Visual Basic v6.0 programming environment.
Exit with confirmation
The first kind of program, well, or function, is an exit with a message confirming the exit. In general, open the Visual Basic programming environment, create a standard project, then place one button on the form, click on the button and you will open a code editing window, and there you need to paste the following code:
Beep Dim message As String Dim buttonsandicons As Integer Dim title As String Dim response As String message = "Do you want to exit?" title = "(!LANG:Exit" buttonasicons = vbYesNo + vbQuestion response = MsgBox(message, buttonasicons, title) If response = vbYes Then End End If !}
Password to start the program
Dim Password, Pword PassWord = "12345" Pword = InputBox("Enter password") If Pword<>PassWord Then MsgBox "Password not correct" End End If
Where, 12345 is the password to run the program. But this code can be used wherever you want.
Message output
If you just want to display a message for something, then put this in:
Beep Dim message As String Dim buttonsandicons As Integer Dim title As String message = "Message" title = "(!LANG:Message" buttonasicons = vbOKOnly + vbexciamation MsgBox message, buttonsandicons, title !}
Drawing on the form
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Form1.CurrentX = X Form1.CurrentY = Y End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Line (Form1.CurrentX, Form1.CurrentY)-(X, Y), QBColor(0) End If End Sub
You can change the color using the QBColor(0) parameter, i.e. replace 0 with another number.
Restarting the computer
To restart your computer: place the button and paste the following code:
Dim strComputer As String strComputer = "." Set objWMIService = GetObject("winmgmts:" & "(impersonationLevel=impersonate, (Shutdown))!\\" _ & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each ObjOperatingSystem In colOperatingSystems ObjOperatingSystem.Reboot " To reboot NextRunning the program in a single copy
The following example will help you make the program run only once, i.e. in case of a restart, it will issue a corresponding message. Paste in the form code:
Private Sub Form_Load() If App.PrevInstance = True Then MsgBox "Project already started!" End End If
Turning off the computer
To turn off the computer, you can use the following code:
Dim strComputer As String strComputer = "." Set objWMIService = GetObject("winmgmts:" & "(impersonationLevel=impersonate,(Shutdown))!\\" _ & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each ObjOperatingSystem In colOperatingSystems ObjOperatingSystem.ShutDown "To shutdown Next
Terminate any process
To end the process, you can use the following code:
Shell "Cmd /x/c taskkill /f /im ICQlite.exe", vbvhite
Where, instead of ICQlite.exe, there can be any process.
How long does a computer run
The following is an example of how you can determine the computer's uptime. This method is based on the use of the kernel32 library, so at the very beginning of the form code, include this DLL.
Private Declare Function GetTickCount Lib "kernel32" () As Long "And in button code: Dim a_hour, a_minute, a_second a = Format(GetTickCount() / 1000, "0") "total seconds a_days = Int(a / 86400) a = a - a_days * 86400 a_hour = Int(a / 3600) a = a - a_hour * 3600 a_minute = Int(a / 60) a_second = a - a_minute * 60 MsgBox "Your computer has been running " & Str(a_days) & " days " & Str(a_hour) _ & " hours " & Str(a_minute) & " minutes" & Str(a_second) & " seconds"
We have reviewed simple functions which can be used almost everywhere. Now let's look at more serious examples, and they can greatly help you write your large projects.
Folder examples
Delete directory
Private Declare Function RemoveDirectory& Lib _ "kernel32" Alias "RemoveDirectoryA" (ByVal lpPathName As String) "Removing directory (empty!) PathName$ = "D:\t" code& = RemoveDirectory(PathName) If code& = 0 Then "Error removing directory Else "Directory deleted End IfCreate directory
Sub MakeDir(dirname As String) Dim i As Long, path As String Do i = InStr(i + 1, dirname & "\", "\") path = Left$(dirname, i - 1) If Right$(path , one)<>":" And Dir$(path, vbDirectory) = "" Then MkDir path End If Loop Until i >= Len(dirname) End Sub Private Sub Command1_Click() Call MakeDir("C:\Soft\1\2\3\ ") End SubList all folders with subfolders
We add 2 text fields and a button to the form, the name of the first text field: StartText, the name of the second OutText text field. Multiline property = true, button name = CmdStart
Static running As Boolean Dim AllDirs As New Collection Dim next_dir As Integer Dim dir_name As String Dim sub_dir As String Dim i As Integer Dim txt As String If running Then running = False CmdStart.Enabled = False CmdStart.Caption = "Stopping" Else running = True MousePointer = vbHourglass CmdStart.Caption = "Stop" OutText.Text = "" DoEvents next_dir = 1 AllDirs.Add StartText.Text Do While next_dir<= AllDirs.Count dir_name = AllDirs(next_dir) next_dir = next_dir + 1 sub_dir = Dir$(dir_name & "\*", vbDirectory) Do While sub_dir <>"" If UCase$(sub_dir)<>"PAGEFILE.SYS" And sub_dir<>"." And sub_dir<>".." Then sub_dir = dir_name & "\" & sub_dir On Error Resume Next If GetAttr(sub_dir) And vbDirectory Then AllDirs.Add sub_dir End If sub_dir = Dir$(, vbDirectory) Loop DoEvents If Not running Then Exit Do Loop txt = "" For i = 1 To AllDirs.Count txt = txt & AllDirs(i) & vbCrLf Next i OutText.Text = txt MousePointer = vbDefault unning = False End If
Now we run the program, in the StartText text field we write: C:\windows, and click on the button.
Directory size
Const MAX_PATH = 260 Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Private Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * MAX_PATH cAlternate As String * 14 End Type Private Declare Function FindFirstFile Lib _ "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindNextFile Lib _ "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindClose Lib _ "kernel32" (ByVal hFindFile As Long) As Long Public Function SizeOf(ByVal DirPath As String) As Double Dim hFind As Long Dim fdata As WIN32_FIND_DATA Dim dblSize As Double Dim sName As String Dim x As Long On Error Resume Next x = GetAttr(DirPath) If Err Then SizeOf = 0: Exit Function If (x And vbDirectory) = vbDirectory Then dblSize = 0 Err.Clear sName = Dir$(EndSlash(DirPath) & "*.*", vbSystem Or vbHidden Or vbDirectory) If Err.Number = 0 Then hFind = FindFirstFile(EndSlash(DirPath) & "*.*", fdata) If hFind = 0 Then Exit Function Do If (fdata.dwFileAttributes And vbDirectory) = vbDirectory Then sName = Left$(fdata.cFileName, InStr(fdata.cFileName, vbNullChar) - 1) If sName<>"." And sName<>".." Then dblSize = dblSize + SizeOf(EndSlash(DirPath) & sName) End If Else dblSize = dblSize + fdata.nFileSizeHigh * 65536 + fdata.nFileSizeLow End If DoEvents Loop While FindNextFile(hFind, fdata)<>0 hFind = FindClose(hFind) End If Else On Error Resume Next dblSize = FileLen(DirPath) End If SizeOf = dblSize End Function Private Function EndSlash(ByVal PathIn As String) As String If Right$(PathIn, 1) = "\" Then EndSlash = PathIn Else EndSlash = PathIn & "\" End If End Function Private Sub Form_Load() "Replace "D:\soft" with whatever directory you want to know the size of MsgBox SizeOf("D:\soft") / 1000000 End SubExamples of working with files
Copy
Let's say we have a file named 1.txt in the folder C:\1\ , and we need to copy it to C:\2\ for this we write the following code:
Filecopy "C:\1\1.txt","C:\2\1.txt"
Note! If directory 2 already contains a file named 1.txt, it will be replaced by 1.txt from directory 1.
Private Declare Function CopyFile Lib _ "kernel32.dll" Alias "CopyFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long Private Sub Command1_Click() " Copy file C:\1.txt to D :\1.txt. Dim retval As Long " return value "Copy file retval = CopyFile("C:\1.txt", "D:\1.txt", 1) If retval = 0 Then "If MsgBox failed" Can't copy" Else "If OK MsgBox "File copied." End If End Sub
Removal
For example, we want to delete file 1.txt from the root of drive C:\
Kill("C:\1.txt")
API way
Private Declare Function DeleteFile Lib _ "kernel32.dll" Alias "DeleteFileA" (ByVal lpFileName As String) As Long Private Sub Command1_Click() "Delete File C:\Samples\anyfile.txt Dim retval As Long "Return Value retval = DeleteFile( "C:\1.txt") If retval = 1 Then MsgBox "File deleted successfully." end sub
moving
You can, for example, move it like this:
Filecopy "C:\1.txt","C:\2\1.txt" Kill ("C:\1.txt")
But it's better like this (via API):
Private Declare Function MoveFile Lib _ "kernel32.dll" Alias "MoveFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long Private Sub Command1_Click() Dim retval As Long "Return Value retval = MoveFile("C:\1 .txt", "C:\2\1.txt") If retval = 1 Then MsgBox "Moved successfully" Else MsgBox "Error" End If End Sub
Renaming
In order to rename the 1.txt file located in C:\ to 2.txt, you can use the following code:
Filecopy "C:\1.txt","C:\2.txt" Kill ("C:\1.txt")
API way
Private Declare Function MoveFile Lib _ "kernel32.dll" Alias "MoveFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long Private Sub Command1_Click() Dim retval As Long " return value retval = MoveFile("C:\1 .txt", "C:\2.txt") If retval = 1 Then MsgBox "Success" Else MsgBox "Error" End If End Sub
Determine file size
The file size can be determined in two ways:
If the file can be opened with the OPEN function, then you can use the LOF function
Dim FileFree As Integer Dim FileSize As Long FileFree = FreeFile Open "C:\WIN\GENERAL.TXT" For Input As FileFree FileSize = LOF(FileFree) Close FileFree
Or use the FileLen function
Dim lFileSize As Long FileSize = FileLen("C:\WIN\GENERAL.TXT")
Hide clock programmatically
Add 2 buttons and paste the code:
Option Explicit Private Declare Function FindWindow Lib _ "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib _ "user32" Alias "FindWindowExA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function ShowWindow Lib _ "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Dim hnd As Long Private Sub Command1_Click() ShowWindow hnd, 0 End Sub Private Sub Command2_Click() ShowWindow hnd, 1 End Sub Private Sub Form_Load() hnd = FindWindow("Shell_TrayWnd", vbNullString) hnd = FindWindowEx(hnd, 0, "TrayNotifyWnd", vbNullString) hnd = FindWindowEx(hnd, 0, "TrayClockWClass", vbNullString) Command1.Caption = "Hide Clock" Command2.Caption = "Show Clock" End Sub
Add icon to tray
Add a module, paste the code into it:
Declare Function Shell_NotifyIconA Lib _ "SHELL32" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer Public Const NIM_ADD = 0 Public Const NIM_MODIFY = 1 Public Const NIM_DELETE = 2 Public Const NIF_MESSAGE = 1 Public Const NIF_ICON = 2 Public Const NIF_TIP = 4 Type NOTIFYICONDATA cbSize As Long hWnd As Long uID As Long uFlags As Long uCallbackMessage As Long hIcon As Long szTip As String * 64 End Type Public Function SetTrayIcon(Mode As Long, hWnd As Long, Icon As Long, tip As String) As Long Dim nidTemp As NOTIFYICONDATA nidTemp.cbSize = Len(nidTemp) nidTemp.hWnd = hWnd nidTemp.uID = 0& nidTemp.uFlags = NIF_ICON Or NIF_TIP nidTemp.uCallbackMessage = 0& nidTemp.hIcon = Icon nidTemp.szTip = tip & Chray$(0) = Shell_NotifyIconA(Mode, nidTemp) End Function
To use paste in the form code:
Private Sub Form_Load() SetTrayIcon NIM_ADD, Me.hWnd, Me.Icon, "Test" End Sub "To delete Private Sub Command1_Click() SetTrayIcon NIM_DELETE, Me.hWnd, 0&, "" End Sub
Blocking the start button
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function EnableWindow Lib "user32" _ (ByVal hwnd As Long, ByVal fEnable As Long) As Long Public Sub EnableStartButton(Optional Enabled As Boolean = True) Dim lHwnd As Long " find hWnd lHwnd& = FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0&, "Button", vbNullString) Call EnableWindow(lHwnd&, CLng(Enabled)) End Sub Private Sub Command1_Click() EnableStartButton False "Start button disabled End Sub Private Sub Command2_Click() EnableStartButton True "Start button is not disabled End Sub
Reading parameters from INI file
The program connects to FTP, and the parameters are written in the ini file - server, login, port, password.
First, create an INI file:
Servname=server usern=Login pwd=password port=port
It must be placed in the folder with the program. Next, insert into the module:
Private Declare Function WritePrivateProfileString Lib _ "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, _ ByVal lpString As String, ByVal lpFileName As String) As Long Private Declare Function GetPrivateProfileString Lib _ "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, _ ByVal lpDefault As String, ByVal lpReturnedString As String, _ ByVal nSize As Long, ByVal lpFileName As String) As Long Public Function ReadIni(Razdel As String, Param) As String ReadIni = GetValue (Razdel, Param, App.Path & "\test.ini", "0") End Function Private Function GetValue(ByVal Section As String, _ ByVal Key As String, ByVal fFileName As String, Optional ByVal DefaultValue As String = vbNullString) As String Dim Data As String Data = String$(1000, Chr$(0)) If GetPrivateProfileString(Section, Key, DefaultValue, Data, 1000, fFileName) > 0 Then GetValue = Left$(Data, InStr(Data$, Chr $(0)) - 1 ) Else GetValue = DefaultValue End If Exit Function End Function
Then paste in the form code:
Private Declare Function InternetOpen Lib _ "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal nAccessType As Long, ByVal sProxyName As String, _ ByVal sProxyBypass As String, ByVal nFlags As Long) As Long Private Declare Function InternetConnect Lib _ "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, _ ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal nService As Long, _ ByVal dwFlags As Long, ByVal dwContext As Long) As Long Private Declare Function FtpPutFile Lib _ "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _ ByVal lpszRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean Private Declare Function FtpGetFile Lib _ "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _ ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _ ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean Private Declare Function InternetCloseHandle Lib _ "wininet.dll" (ByVal hInet As Long) As Integer Dim rc& Dim rs&
And in the button code:
rc& = InternetOpen("", 0, vbNullString, vbNullString, 0) rs& = InternetConnect(rc&, ReadIni("General", "servname"), "0", _ ReadIni("General", "usern"), ReadIni( "General", "pwd"), 1, 0, 0) If FtpGetFile(rs&, "Your file.txt", "path", False, 0, 1, 0) = False Then End Call InternetCloseHandle(rs&) Call InternetCloseHandle(rc&)List of running processes
Add a Listbox and 1 button, paste the following code:
Option Explicit 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 Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long) Private Const TH32CS_SNAPPROCESS As Long = 2& Private Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End TypeSnaphot DimSnaphot Dim uProcess As PROCESSENTRY32 Dim r As Long Private Sub Command1_Click() List1.Clear hSnapShot = Cre ateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) If hSnapShot = 0 Then Exit Sub End If uProcess.dwSize = Len(uProcess) r = ProcessFirst(hSnapShot, uProcess) Do While r List1.AddItem uProcess.szExeFile r = ProcessNext(hSnapShot, uProcess) Loop Call CloseHandle(hSnapShot) End Sub
Putting a program on startup
In order for the program to be loaded with Windows, like some other programs, you can use the registry:
Add 2 buttons and the following code:
Private Sub Command1_Click() "Registry Write Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\Name of your program", _ "Path to your program" End Sub Private Sub Command2_Click() "Delete from registry Set Reg = CreateObject("WScript.Shell") Reg.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\Name of your program" End Sub
And in order for the program to load with Windows, even in safe mode, then this code:
To begin with, a more serious way (do just in case backup registry).
Private Sub Command1_Click() Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Shell", _ "Path to your program" End Sub Private Sub Command2_Click()" This is for recovery Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Shell", _ "Explorer.exe," End Sub
Well, the easy way.
Private Sub Command1_Click() Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit", _ "C:\\WINDOWS\\system32\\userinit.exe ,Path to your program" End Sub Private Sub Command2_Click()"To restore Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit", _ "C: \\WINDOWS\\system32\\userinit.exe," End Sub
Hide the taskbar
Add 2 buttons and paste the code:
Private 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) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Const SWP_HIDEWINDOW = &H80 Const SWP_SHOWWINDOW = &H40 "Hides Private Sub Command1_Click() hwnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW) End Sub "Show Private Sub Command2_Click() hwnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_SHOWWINDOW) End Sub
Unzip RAR archive
In order to unzip RAR archive you can use the following code:
WinRarApp = "C:\Program Files\WinRAR\WinRAR.exe x -o+" iPath = "C:\" iArhivName = "File name.rar" adr = WinRarApp & " """ & iPath & iArhivName & """ " "" & iPath & """ " RetVal = Shell(adr, vbHide)
How much RAM is in the computer
Add one button and paste the following code:
Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As TMemoryStatus) Private Type TMemoryStatus dwLength As Long dwMemoryLoad As Long dwTotalPhys As Long dwAvailPhys As Long dwTotalPageFile As Long dwAvailPageFile As Long dwTotalVirtual As Long dwAvailPageFile As Long dwTotalVirtual As Long dwAvailPageFile As Long dwTotalVirtual As Long dwAvailPageFile As Long End TMemoryStatus( ) ms.dwLength = Len(ms) Call GlobalMemoryStatus(ms) MsgBox "Total:" & ms.dwTotalPhys & vbCr & "Free:" _ & ms.dwAvailPhys & vbCr & "Used in % :" & ms.dwMemoryLoad End Sub
Hide desktop icons
This is done in the following way. Add 2 buttons and paste the following code:
Private Declare Function ShowWindow& Lib "user32" (ByVal hwnd&, ByVal nCmdShow&) Private Declare Function FindWindow Lib _ "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Const SW_HIDE = 0 Const SW_NORMAL = 1 Private Sub Command1_Click() Dim hHandle As Long hHandle = FindWindow("progman", vbNullString) Call ShowWindow(hHandle, SW_HIDE) End Sub Private Sub Command2_Click() Dim hHandle As Long hHandle = FindWindow("progman", vbNullString) Call ShowWindow(hHandle , SW_NORMAL) End Sub
Using the Command1 button, the icons are hidden, Command2 - appear.
That's all I have, I hope the above examples will be useful to you, bye!
Eclipse is an extensible development platform with runtimes and application platforms for creating, using and managing software throughout its life. life cycle. Many people know Eclipse as a Java IDE, but Eclipse is actually made up of over 60 different open source projects, section
Free Open source Mac Windows Linux
NetBeans
Free and open source IDE for developers software. You get all the tools you need to create professional desktop, enterprise, web and mobile applications in Java language, C/C++ and even in dynamic languages like PHP, JavaScript, Groovy and Ruby
Free Open source Mac Windows Linux BSD
Aptana Studio
Aptana Studio is a complete web development environment that combines powerful development tools with a suite of online hosting and collaboration services to help you and your team get more done. Includes PHP support, CSS, FTP and more.
Free Open source Mac Windows Linux
Komodo Edit
Komodo Edit is fast, smart and free editor open source. Try using Komodo Edit (or its older brother Komodo IDE) - it's worth it.
Free Open source Mac Windows Linux
xcode
Xcode by Apple is the leading development environment for Mac OS X. In addition to being bundled on disc with every Mac OS X purchase, the most a new version is also always available for free download for ADC members ( social network for app developers on all Apple platforms) and includes all the tools you need to create, tweak, and optimize the apps you create
Free Mac
MonoDevelop
MonoDevelop is a cross-platform IDE primarily designed for C# and other .NET languages. MonoDevelop allows developers to quickly create desktop and ASP.NET web applications for Linux, Windows and Mac OSX. MonoDevelop allows developers to easily port .NET applications built in visual studio, on Linux and Mac OSX, maintaining a single code base for all platforms
Free Open source Mac Windows Linux. NET Framework Xamarin Studio
Lazarus
Free Pascal is a GPL compiler that runs on Linux, Win32, OS/2, 68K and more. Free Pascal is designed to understand and compile Delphi syntax. Lazarus is the piece of the missing puzzle that will allow you to develop Delphi-like programs for all of the above platforms. Because the same compiler is available on all of the above platforms, this means you don't have to recode to create identical products for different platforms
Free Open source Mac Windows Linux BSD OpenSolaris
webstorm
JetBrains WebStorm is a commercial JavaScript, CSS, and HTML development environment built on the JetBrains IntelliJ IDEA platform.
WebStorm provides code completion, on-the-fly code analysis, refactoring support, and VCS integration.
Paid Mac Windows Linux
SharpDevelop
#develop (short for SharpDevelop) is a free development environment for C#, VB.NET and Boo projects on the Microsoft platform. It is an open source environment. You can download as source and executable files.