Vb za pocetnike, poznavaoce,profesionalce -primeri i trikovi

6

Vb za pocetnike, poznavaoce,profesionalce -primeri i trikovi

offline
  • Pridružio: 20 Apr 2006
  • Poruke: 93

Kako da napravim okruglu formu, ili elipsastu. Naravno iskoristio bih neku sliku za pozadinu forme.



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • Pridružio: 28 Jun 2004
  • Poruke: 990
  • Gde živiš: Kucura

VB Shaped Form Creator



offline
  • dubu 
  • Novi MyCity građanin
  • Pridružio: 30 Sep 2006
  • Poruke: 3

Kako pomocu VB-a sakriti i prikazati TaskBar?

Sakrivanje
hwnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)

Prikazivanje
hwnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW) Call SetWindowPos(hwnd1, 0,

Kako pomocu VB-a promeniti pozadinu Desktopa?

U modul
Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long Public Const SPI_SETDESKWALLPAPER = 20

U komandi
Dim ChangeWP Dim source As String source = "putanja i naziv slike" ChangeWP = SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, source, 1)


Ukoliko vam se dopada, rado cu podeliti jos neke sa vama, samo mi dajte vremena da ih sredim i ucinim citljivim

DOPUNA:

Kako pozvati office asistenta i kontrolisati ga?

Ucitavanje:

Dim FormLeft As Integer Dim FormTop As Integer Dim LocalPath As String Dim AgentName As String Dim Agent Private Sub Form_Load() LocalPath = "C:\Windows\MSAgent\Chars\" AgentName = "Merlin" Set Agent = CreateObject("agent.control.1") Agent.connected = True Agent.Characters.Load AgentName, LocalPath & AgentName & ".acs" Agent.Characters(AgentName).Show End Sub

Kontrola:
Private Sub Command1_Click() Agent.Characters(AgentName).Play 'evde uneti jednu od dole postavljenuh komandi End Sub "Confused" "Search" "DontRecognize" "Explain" "Pleased" "Wave" "Congratulate" "Greet" "Process" "Write"

Kako otvoriti i zatvoriti primarni cd uredjaj pomocu VB-a?

Private Declare Function mciSendString Lib "winmm.dll" Alias"mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long 'SVE TREBA BITI U JEDNOM REDU Private Sub otvori_Click() retvalue = mciSendString("set CDAudio door open", returnstring, 127, 0) End Sub Private Sub zatvori_Click() retvalue = mciSendString("set CDAudio door closed", returnstring, 127, 0) End Sub

DOPUNA:

kako iskljuciti kompjuter?

Private Const EWX_SHUTDOWN As Long = 1 Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long Private Sub Command1_Click() lngResult = ExitWindowsEx(EWX_SHUTDOWN, 0&) End Sub

Kako se izlogovati iz Windowsa?

Private Const EWX_LogOff As Long = 0 Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long Private Sub Command1_Click() lngResult = ExitWindowsEx(EWX_LogOff, 0&) End Sub

Kako restartovati kompjutrer?

Private Const EWX_REBOOT As Long = 2 Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long Private Sub Command1_Click() lngResult = ExitWindowsEx(EWX_REBOOT, 0&) End Sub

kako sakriti kursor?

u modulu:

Declare Function ShowCursor& Lib "user32" (ByVal bShow As Long)

u komandi:

Private Sub sakri_Click() ShowCursor (False) End Sub Private Sub vrati_Click() ShowCursor (True) End Sub


Novak Bulajic
2006
nbulajic@yahoo.com

offline
  • Pridružio: 28 Jun 2004
  • Poruke: 990
  • Gde živiš: Kucura

[url=https://www.mycity.rs/must-login.png koji proverava tacnost IP adrese[/url]

Dopuna: 08 Apr 2007 16:49

Forma ostaje na starom mestu

Neznam kako bi ovo nazvao ali sluzi da kada pokrenete program, pomerite formu negde, ugasite progi, i ponovo ukljucite prog, forma ce se pojaviti na starom mestu.

U modul:
Dim frm As Form1 Dim fname, x, y As String Public Sub save_position() fname = "position" x = Form1.Top y = Form1.Left If Dir(App.Path & "\" & fname) <> "" Then Kill App.Path & "\" & fname Open App.Path & "\" & fname For Output As #1 Print #1, x & ";" & y Close #1 End Sub Public Sub open_position() Dim pos, a() As String fname = "position" If Dir(App.Path & "\" & fname) <> "" Then     Open App.Path & "\" & fname For Input As #1         pos = Input(LOF(1), 1)     Close #1     a = Split(pos, ";")     x = a(0)     y = a(1)     Form1.Top = x     Form1.Left = y End If End Sub

U formu
Private Sub Form_Load() open_position End Sub Private Sub Form_Unload(Cancel As Integer) save_position End Sub

Dopuna: 08 Apr 2007 17:08

Sifrovanje texta

Sifrujte svoj text da ga ostali ne mogu procitati Wink Treba da stavite 2 textbox-a na formu.

U Modul:
Public Sub Decipher(ByVal password As String, ByVal from_text As String, to_text As String) On Error Resume Next Const MIN_ASC = 32 Const MAX_ASC = 126 Const NUM_ASC = MAX_ASC - MIN_ASC + 1 Dim offset As Long Dim str_len As Integer Dim i As Integer Dim ch As Integer offset = NumericPassword(password) Rnd -1 Randomize offset str_len = Len(from_text) For i = 1 To str_len ch = Asc(Mid$(from_text, i, 1)) If ch >= MIN_ASC And ch <= MAX_ASC Then ch = ch - MIN_ASC offset = Int((NUM_ASC + 1) * Rnd) ch = ((ch - offset) Mod NUM_ASC) If ch < 0 Then ch = ch + NUM_ASC ch = ch + MIN_ASC to_text = to_text & Chr$(ch) End If Next i End Sub Public Function NumericPassword(ByVal password As String) As Long On Error Resume Next Dim value As Long Dim ch As Long Dim shift1 As Long Dim shift2 As Long Dim i As Integer Dim str_len As Integer str_len = Len(password) For i = 1 To str_len ch = Asc(Mid$(password, i, 1)) value = value Xor (ch * 2 ^ shift1) value = value Xor (ch * 2 ^ shift2) shift1 = (shift1 + 7) Mod 19 shift2 = (shift2 + 13) Mod 23 Next i NumericPassword = value End Function Public Sub Cipher(ByVal password As String, ByVal from_text As String, to_text As String) On Error Resume Next Const MIN_ASC = 32 Const MAX_ASC = 126 Const NUM_ASC = MAX_ASC - MIN_ASC + 1 Dim offset As Long Dim str_len As Integer Dim i As Integer Dim ch As Integer offset = NumericPassword(password) Rnd -1 Randomize offset str_len = Len(from_text) For i = 1 To str_len ch = Asc(Mid$(from_text, i, 1)) If ch >= MIN_ASC And ch <= MAX_ASC Then ch = ch - MIN_ASC offset = Int((NUM_ASC + 1) * Rnd) ch = ((ch + offset) Mod NUM_ASC) ch = ch + MIN_ASC to_text = to_text & Chr$(ch) End If Next i End Sub

U formu:
'za sifrovanje cipher("sifra",text1.text,text2.text)

'za desifrovanje decipher("sifra",text2.text,text1.text)

Dopuna: 09 Apr 2007 16:43

Kako registrovati extenzije za vas program?

Downloadujte [url=https://www.mycity.rs/must-login.png (desni klik\save target as...) i ubacite ga u vas projekat.



1) Kada zelite da registrujete extenziju:

Citat:
MakeFileAssociation(Extension, PathToApplication, ApplicationName, Description, Optional FullIconPath)

Where:

Extension (string) - Your new filetypes extension (without the point !)
PathToApplication (string) - The full path (without exe name) of your program
ApplicationName (string) - The exe name (including .exe)
Description (string) - Description of the filetype as shown in the explorer
FullIconPath (string) - Full path of the associated icon (including .ico)


Primer:

MakeFileAssociation "abc", App.Path, App.EXEName, "Test extenzija", "c:\icon.ico"

--------------------------------------------------

2) Kada zelite da proverite koji se program koristi za otvaranje fajlova sa nekom extenzijom:


Citat:
return = CheckFileAssociation(Extension)

Where:

Extension (string) - The filetypes extension you want to verify
return (string) - the name of the associated exe, or empty if no associated exe-file exists


Primer:

a = CheckFileAssociation("abc")

--------------------------------------------------

3) Kada vise ne zelite da vas program otvara neku vrstu extenzije:

Citat:
DeleteFileAssociation(Extension)

Where:

Extension (string) - The filetypes extension you want to delete(without the point !)


Primer:

DeleteFileAssociation "abc"

offline
  • Pridružio: 27 Apr 2007
  • Poruke: 28
  • Gde živiš: kraljevina MIRIJEVO!

Ludu svaka cast na trudu. Ja sam pocetnik pa je ovo mozda glupo pitanje. GDE JE MODUL? STA JE TO?

offline
  • Pridružio: 28 Jun 2004
  • Poruke: 990
  • Gde živiš: Kucura

hmm.. Tamo gore gde ti pise File, View, Edit... Imas 'Project'. Klikni tu pa klik na 'Add module' , zatim na 'Open'. Tako si ubacio modul u svoj projekat. Sada se on nalazi sa desne strane u 'Project Explorer'-u. Dupli klik na njega i videces sta ima u njemu, da upises code.... Wink

A sta je to tacno.. neznam ni ja, jer sam preskocio teoriju programiranja Razz

Dopuna: 27 Apr 2007 13:39

Citat: Modules?

What is a module you ask? A module is used to store all your functions and public routines seperately. Apart from it keeping your code editors window clean, it removes the need for repetitive typing. For example, it is better to add code to a module and use 1 line to call it when needed, then to repeat the same code over and over. This code from the module Exits the program when needed:

Public Sub ExitProgram()
Unload frmMain
End Sub

It has to be named Public so VB knows it is available to all forms. Now, from the form, this code is called when you click either the File > Exit menu item or the Exit Command button, like so (This code goes in your form's code window):

Private Sub mnuFileExit_Click()
Call ExitProgram
End Sub

Private Sub cmdExit_Click()
Call ExitProgram
End Sub

Although there is no significant size difference in using the code form the module, as there is using it in your form's code, it saves time and space later on when dealing with larger code!


http://www.vbforums.com/archive/index.php/t-281623.html

offline
  • Pridružio: 27 Apr 2007
  • Poruke: 28
  • Gde živiš: kraljevina MIRIJEVO!

Hvala brate Smile

offline
  • Pridružio: 28 Jun 2004
  • Poruke: 990
  • Gde živiš: Kucura

np, tu smo da pomognemo Wink
btw. Dobrodosao na forum Zagrljaj

Dopuna: 29 Apr 2007 1:54

Evo recimo ako imate neku liniju na formi (sta ja znam pravite prog za crtanje ili nesto drugo...) i zelite da izracunate koliko je dugacka, iskoristite ovu funkciu:

Public Function length(line_x1, line_y1, line_x2, line_y2) Dim x(2), y(2) As String Dim a, b As String x(1) = line_x1 x(2) = line_x2 y(1) = line_y1 y(2) = line_y2 If x(1) = x(2) And y(1) = y(2) Then     length = 0     Exit Function End If If x(1) = x(2) Then     length = Abs(y(2) - y(1))     Exit Function End If If y(1) = y(2) Then     length = Abs(x(2) - x(1))     Exit Function End If a = Abs(x(1) - x(2)) b = Abs(y(1) - y(2)) length = Round(Sqr(a * a + b * b), 0) End Function

offline
  • Pridružio: 27 Apr 2007
  • Poruke: 28
  • Gde živiš: kraljevina MIRIJEVO!

Hvala na dobrodoslici.
Ja sam tek poceo, napravio sam par obicnih programcica.
Ali voleo bih da napravim prog. za crtanje ili za slusanje muzike...

Dopuna: 29 Apr 2007 9:23

Dejan123 ::Mnooogo kraci nacin:
U modul:
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

U command click:
lngReturn = mciSendString("set CDAudio door open", strReturn, 127, 0)

A da se zatvori ista deklaracija samo se u command click stavlja:
lngReturn = mciSendString("set CDAudio door closed", strReturn, 127, 0)


Ovaj Kod NE RADI.
Dajte mi neki kod za zatvaranje CD-a, posto sam napravio programcic u kojem postoji opcija otvori cd...

Dopuna: 29 Apr 2007 9:33


Citat:DOPUNA:

kako iskljuciti kompjuter?

Private Const EWX_SHUTDOWN As Long = 1 Private Declare Function ExitWindowsEx Lib \"user32\" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long Private Sub Command1_Click() lngResult = ExitWindowsEx(EWX_SHUTDOWN, 0&) End Sub

Kako se izlogovati iz Windowsa?

Private Const EWX_LogOff As Long = 0 Private Declare Function ExitWindowsEx Lib \"user32\" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long Private Sub Command1_Click() lngResult = ExitWindowsEx(EWX_LogOff, 0&) End Sub

Kako restartovati kompjutrer?

Private Const EWX_REBOOT As Long = 2 Private Declare Function ExitWindowsEx Lib \"user32\" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long Private Sub Command1_Click() lngResult = ExitWindowsEx(EWX_REBOOT, 0&) End Sub





Aj ako neko zna nek napise gde koji kod ide. Vidim da je prvi na dugmetu ali drugi...?

offline
  • Pridružio: 28 Jun 2004
  • Poruke: 990
  • Gde živiš: Kucura

Za otvaranje/zatvaranje vratanca CD citaca:

[url=https://www.mycity.rs/must-login.png

Dopuna: 30 Apr 2007 20:15

Imao si i ovo sto je dubu napisao:

Private Declare Function mciSendString Lib "winmm.dll" Alias"mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long 'SVE TREBA BITI U JEDNOM REDU Private Sub otvori_Click() retvalue = mciSendString("set CDAudio door open", returnstring, 127, 0) End Sub Private Sub zatvori_Click() retvalue = mciSendString("set CDAudio door closed", returnstring, 127, 0) End Sub

Dopuna: 30 Apr 2007 20:17

Citat:
Aj ako neko zna nek napise gde koji kod ide. Vidim da je prvi na dugmetu ali drugi...?


Svi idu na dugme...

Ko je trenutno na forumu
 

Ukupno su 986 korisnika na forumu :: 26 registrovanih, 0 sakrivenih i 960 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: A.R.Chafee.Jr., Andrija357, banebeograd, Boris BM, Dannyboy, delboy, djboj, Djokislav, esx66, HrcAk47, Ksh037, Lazarus, Milos82, milutin134, Mixelotti, nikoladim, ozzy, Rogonos, S.Palestinac, S2M, Sass Drake, stagezin, Trpe Grozni, vladetije, vladulns, 79693