try to using Shell() function :
Shell("D:\keygen.exe")
try to using Shell() function :
Shell("D:\keygen.exe")
yes, thats right...
add this following code in your module :
Public Sub RetrieveIcon(fName As String, DC As PictureBox, icnSize As IconRetrieve)
Dim hImgSmall, hImgLarge As Long 'the handle to the system image list
DC.Cls
Select Case icnSize
Case ricnSmall
hImgSmall = SHGetFileInfo(fName$, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_SMALLICON)
Call ImageList_Draw(hImgSmall, shinfo.iIcon, DC.hDC, 0, 0, ILD_TRANSPARENT)
Case ricnLarge
hImgLarge& = SHGetFileInfo(fName$, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_LARGEICON)
Call ImageList_Draw(hImgLarge, shinfo.iIcon, DC.hDC, 0, 0, ILD_TRANSPARENT)
End Select
End Sub
this function will called like this :
RetrieveIcon lblPath.Caption, PicIcon32, ricnLarge
PicIcon32 is picturebox
hope this helps...
hmmm. i never do this but i think you can run the exe file.
Add in your declaration :
Const MAX_PATH As Integer = 260
set BorderStyle of Form properties to None
Picture1.Picture = LoadPicture("F:\Pictures\Icon\CloseX.ico")
Hi..
File ->Make YourProjectName.Exe
COUNT function to count how much record in current column.
SUM function to added all value in current column.
AVG function to get average of all value in current column.
etc...
Well Great to solved your thread by your self.
Happy coding friend :)
you're Welcome friend :)
Happy Coding.
use tab index to set cursor on current text box.
setfocus cannot be called in form load. just in procedure or function.
Private Sub Command2_Click()
Call clear
End SubPublic Sub clear()
Dim txt As Control
For Each txt In Controls
If TypeOf txt Is TextBox Then
txt.Text = ""
End If
Next
your code for vb 6 sonia :)
add this code to module to connected sqlserver with vb.net:
Imports System.Data
Imports System.Data.SqlClient
Module Koneksi
Public conn As SqlConnection
Public Function GetConnect()
conn = New SqlConnection("server = MyServerName;database = MyDatabaseName;Trusted_Connection = yes")
Return conn
End Function
End Module
add this code to button event click :
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim check As Integer
Dim conn As SqlConnection
Dim cmdStudent As New SqlCommand
Dim cmdStudent1 As New SqlCommand
Dim daStudent As New SqlDataAdapter
Dim dsStudent As New DataSet
Dim dtStudent As New DataTable
If txtId.text = "" Or txtFirstName.Text = "" txtLastName.Text = "" Or txtAge.Text = "" Then
MsgBox("Student Data is not completed", MsgBoxStyle.OKOnly)
Else
If MsgBox("Are you sure to save Student data with Id : " & txtId.text & " ?", MsgBoxStyle.OKCancel, "Input confirm") = MsgBoxResult.Cancel Then
' do nothing
Else
Try
conn = GetConnect()
conn.Open()
cmdStudent = conn.CreateCommand
cmdStudent.CommandText = "SELECT * FROM Student WHERE Id='" & Trim(txtId.text) & " ' "
daStudent.SelectCommand = cmdStudent
daStudent.Fill(dsStudent, "Student")
dtStudent = dsStudent.Tables("Student")
If (dtStudent.Rows.Count > 0) Then
MsgBox("Student dengan Id " & Trim(cmbId.Text) & " already in database", MsgBoxStyle.OKOnly, "Message :")
Else
cmdStudent1 = conn.CreateCommand
cmdStudent1.CommandText = "INSERT INTO Student(Id, FirstName, LastName,Age) VALUES('" & Trim(txtId.text) & "','" & Trim(txtFirstName.Text) & "','" & Trim(txtLastName.Text) & "','" & Trim(txtAge.Text) & "')"
check = cmdStudent1.ExecuteReader.RecordsAffected()
If check > 0 Then
MsgBox("Student With Id " & Trim(cmbId.Text) & " succesfully to added", MsgBoxStyle.OKOnly, "Message :")
Else
MsgBox("Student With Id " & Trim(cmbId.Text) …
# To add a Date Time Picker control, on the Toolbox, click the More Controls button
# Scroll down in the list of controls, click Microsoft Date and Time Picker 6.0 (SP4), and click the form.
see this tutorial
i tried this with 2 listbox and 1 button. i was moved item on list2 to list5 and remove current item after moved.
Private Sub Form_Load()
With List2
.AddItem ("1")
.AddItem ("2")
.AddItem ("3")
End With
Private Sub Command4_Click()
List5.AddItem List2.ItemData(List2.ListIndex)
List2.RemoveItem List2.ItemData(List2.ListIndex)
End Sub
End Sub
try this :
Label1.Text = Microsoft.Visualbasic.Mid("November"3,3)
use Microsoft Multimedia Control. find this control on component.
add this code to play mp3 file :
On Error GoTo ErrMsg
AxMMControl1.Wait = True
AxMMControl1.FileName = OpenFileDialog1.FileName
AxMMControl1.Command = "Open"
AxMMControl1.Command = "Play"
Exit Sub
ErrMsg:
MsgBox(Err.Description)
End Sub
what the problem with storing in variable???
total1 = textbox1.text
total2 = textbox2.text
sign = combobox1.SelectedItem
well great, i want to answer but you have done it.
With lstReorder
.AddItem (ITEM_NUMBER.Text)
.AddItem (ITEM_DESCRIPTION_1.Text)
End With
i was modified your code.
your messagebox parameter is not completed, that why errors coming out.
Private Sub xExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Dim button As DialogResult
button = MessageBox.Show _
("Are you sure you want to exit this application?", _
"Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
If button = Windows.Forms.DialogResult.Yes Then
Me.Close()
Else
End If
End Sub
btw this thread for vb.net question not for vb6...
handle it with keydown event :
private void TextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
MessageBox.Show("you pressed delete key");
}
}
yeah..you're welcome :)
I added one line code...see the red one :
private void cmdtam_Klik(object sender, EventArgs e)
{
string cstr;
cstr = "data source=knight;initial catalog=latihan;uid=sa;pwd=sri";
SqlConnection con1 = new SqlConnection(cstr);
con1.Open();
SqlCommand com1 = new SqlCommand();
com1.Connection = con1;
com1.CommandType = CommandType.Text;
com1.CommandText = "select * from customer"
DataSet ds1 = new DataSet();
SqlDataAdapter adp1 = new SqlDataAdapter(com1);
adp1.Fill(ds1,"customer");
grd1.DataSource = ds1;
grd1.DataMember = "customer";
con1.Close();
}
your code not set data source of data grid with your dataset(ds1)...
Hope this helps
txtCustomerID.Text = ""
txtCustomerName.Text = ""
txtTelephoneNumber.Text = ""
why you put this code on your add New item event??
it will make none data to insert in database cause you have to clear them before you add them into db.
if you want to clear textbox make a new button to handle this.
ex:
Private Sub btnClearForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearForm.Click
txtCustomerID.Text = ""
txtCustomerName.Text = ""
txtTelephoneNumber.Text = ""
End Sub
So erase that codes from your input button.
I just wanted to ask you guys how should I proceed with this thing..
more clearly...
u mean the business process??
do you want to populate data in datagrid or other control (label or textbox).
i looks in your code you able to populate in datagrid. so try this to populate in textbox or label.
add this code on your code :
If myReader.HasRows Then
While myReader.Read()
txtFirstName.text= myReader.Item("FirstName")
End While
End If
myReader.Close()
yes, here it is the code, try it and let me know if it worked :
Dim AllDir
Private Sub Form_Load()
On Error Resume Next
For i = 65 To 90
x = Dir(Chr(i) & ":\", vbDirectory + vbHidden + vbSystem)
If Err = 52 Then
Err.Clear
Else
If x <> "" Then AllDir = AllDir & (Chr(i) & ":\")
Err.Clear
End If
Next i
MsgBox AllDir
End Sub
Hope this helps...
tell me if this code worked...
try this following code vega :
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Type SYSTEM_INFO
dwOemID As Long
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOrfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
dwReserved As Long
End Type
Private Sub Form_Load()
Dim SInfo As SYSTEM_INFO
'Set the graphical mode to persistent
Me.AutoRedraw = True
'Get the system information
GetSystemInfo SInfo
'Print it to the form
MsgBox "Number of procesor:" + Str$(SInfo.dwNumberOrfProcessors) & vbCrLf & _
"Processor:" + Str$(SInfo.dwProcessorType) & vbCrLf & _
"Low memory address:" + Str$(SInfo.lpMinimumApplicationAddress) & vbCrLf & _
"High memory address:" + Str$(SInfo.lpMaximumApplicationAddress)
Unload Me
End Sub
awesome
both of you is a great coder...thanks for all your helps guys
i m very happy :D
Thank you...
We just give what we know and glad to share our knowledge :)
Happy coding Friend.
don't felt that, i really like your code.
i happy to know much from you too. you are the great coder, your code always help me and others. So, many alternative solution make it more completed.
you're welcome friend :)
try this following code :
'This project needs
' -a Command Button (Command1)
' -a CommonDialog (CommonDialog1)
' -a Label (Label1)
Private Const OF_READ = &H0&
Private Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Private Declare Function lclose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Dim lpFSHigh As Long
Public Sub GetInfoF(FilePath As String)
Dim Pointer As Long, sizeofthefile As Long
Pointer = lOpen(FilePath, OF_READ)
'size of the file
sizeofthefile = GetFileSize(Pointer, lpFSHigh)
Label1.Caption = sizeofthefile & " bytes"
lclose Pointer
End Sub
Private Sub command1_Click()
CommonDialog1.ShowOpen
GetInfoF CommonDialog1.filename
End Sub
Private Sub Form_Load()
With CommonDialog1
.DialogTitle = "Select a file"
.Filter = "All the files|*.*"
End With
Command1.Caption = "Select a file"
End Sub
Hope this helps...
see this following code :
needed 4 check box, 1 textbox and 2 button.
Dim NamaFile As String
Private Sub Command1_Click()
Cmd.Filter = "All Files|*.*"
Cmd.DialogTitle = "Select Target"
Cmd.ShowOpen
NamaFile = Cmd.FileName
Text1.Text = NamaFile
End Sub
Private Sub Command2_Click()
Dim NilaiAttributes As Byte
If NamaFile <> "" Then
NilaiAttributes = (Check1.Value * 2) + (Check2.Value * 4) + _
(Check3.Value * 1) + (Check1.Value * 32)
SetAttr NamaFile, NilaiAttributes
MsgBox "Set attributes successfull", vbInformation, "Setting Attributes"
End If
End Sub
Private Sub Text1_Change()
NamaFile = Text1.Text
End Sub
Private Sub Text1_GotFocus()
NamaFile = Text1.Text
End Sub
Hope this helps...
you can also use media player control object.
add this from component.
on the form load
Me.WindowState = FormWindowState.Maximized
AxMediaPlayer1.FileName = "C:\movie1.avi"
AxMediaPlayer1.Play()
AxMediaPlayer1.ShowControls = False
AxMediaPlayer1.AllowChangeDisplaySize = False
AxMediaPlayer1.EnableContextMenu = False
AxMediaPlayer1.ClickToPlay = False
AxMediaPlayer1.SendKeyboardEvents = False
Me.Cursor.Hide()
At the end of stream event
Private Sub AxMediaPlayer1_EndOfStream(ByVal sender As Object, ByVal e As AxMediaPlayer._MediaPlayerEvents_EndOfStreamEvent) Handles AxMediaPlayer1.EndOfStream
AxMediaPlayer1.FileName = "C:\movie2.avi"
AxMediaPlayer1.Play()
End Sub
on the form unload , set back the cursor
Me.Cursor.Show()
use a Process, and simply "run" the file (If you happen to know the parameters for launching in fullscreen, then add that too).
Dim prc As New Process
prc.StartInfo.FileName = "C:\mediafile.avi"
prc.StartInfo.Arguments.Insert(0, "-Fullscreen")
prc.Start()
'This project needs a timer,Interval 1000 for normally
'In general section
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Const Invert = 1
Private Sub Timer1_Timer()
'Flash the window
FlashWindow Me.hwnd, Invert
End Sub
try this followong code :
'This example requires two command buttons
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function CopyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Private Declare Function SetSystemCursor Lib "user32" (ByVal hcur As Long, ByVal id As Long) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Const OCR_NORMAL As Long = 32512
Private currenthcurs As Long
Private tempcurs As Long
Private newhcurs As Long
Private Sub Command1_Click()
Dim myDir As String
Dim lDir As Long
myDir = Space(255)
currenthcurs = GetCursor()
tempcurs = CopyIcon(currenthcurs)
lDir = GetWindowsDirectory(myDir, 255)
myDir = Left$(myDir, lDir) & "\cursors\banana.ani"
newhcurs = LoadCursorFromFile(myDir)
Call SetSystemCursor(newhcurs, OCR_NORMAL)
End Sub
Private Sub Command2_Click()
Call SetSystemCursor(tempcurs, OCR_NORMAL)
End Sub
Hope this helps...
yeah...you're welcome :)
try this following code :
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function PrinterProperties Lib "winspool.drv" (ByVal hwnd As Long, ByVal hPrinter As Long) As Long
Private Sub Form_Load()
Dim hPrinter As Long
OpenPrinter Printer.DeviceName, hPrinter, ByVal 0&
PrinterProperties Me.hwnd, hPrinter
ClosePrinter hPrinter
End Sub
hope this helps...
don't forget to give a feedback :)
you're welcome friend.
Happy coding :)
try this following code :
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" (ByVal hPrinter As Long, ByVal FirstJob As Long, ByVal NoJobs As Long, ByVal Level As Long, pJob As Any, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long
Private Sub Form_Load()
Dim hPrinter As Long, lNeeded As Long, lReturned As Long
Dim lJobCount As Long
OpenPrinter Printer.DeviceName, hPrinter, ByVal 0&
EnumJobs hPrinter, 0, 99, 1, ByVal 0&, 0, lNeeded, lReturned
If lNeeded > 0 Then
ReDim byteJobsBuffer(lNeeded - 1) As Byte
EnumJobs hPrinter, 0, 99, 1, byteJobsBuffer(0), lNeeded, lNeeded, lReturned
If lReturned > 0 Then
lJobCount = lReturned
Else
lJobCount = 0
End If
Else
lJobCount = 0
End If
ClosePrinter hPrinter
MsgBox "Jobs in printer queue: " + CStr(lJobCount), vbInformation
End Sub
try this following code :
Private Const SND_APPLICATION = &H80 ' look for application specific association
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
Private Const SND_PURGE = &H40 ' purge non-static events for task
Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
Private Const SND_SYNC = &H0 ' play synchronously (default)
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub
on combo box properties, set for DropDownStyle = DropDownList
yup, do as techtix and debasisdas said...
you need to exit the procedure or function first then go to handler.
you're welcome my friend.
don't forget to mark this thread solved :)