but their is an error saying that it is invalid password
It means your password in connection is wrong.
change this MyDbPassword with your own password.
but their is an error saying that it is invalid password
It means your password in connection is wrong.
change this MyDbPassword with your own password.
It should be like this :
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;
Using what db?
post your connection code.
Try this :
Public Function ChangeFileExt(ByVal FileName As String, ByVal Extention As String)
Dim str() As String, NewFile As String
If InStr(1, FileName, ".") Then
str = Split(FileName, ".")
NewFile = Replace(FileName, str(UBound(str)), Extention)
Name FileName As NewFile
Else
Name FileName As FileName & "." & Extention
End If
End Function
Private Sub Command1_Click()
Call ChangeFileExt("D:\test.jx", "txt")
End Sub
See if this help :
Private Sub ListFiles(strPath As String, Optional Extention As String)
'Leave Extention blank for all files'
Dim File As String
If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"
If Trim$(Extention) = "" Then
Extention = "*.*"
ElseIf Left$(Extention, 2) <> "*." Then
Extention = "*." & Extention
End If
File = Dir$(strPath & Extention)
Do While Len(File)
List1.AddItem File
File = Dir$
Loop
End Sub
Private Sub Command1_Click()
ListFiles "D:\musicfolder", "*"
' Or ListFiles "D:\musicfolder", "" leave it blank to get all files'
End Sub
Try this :
Private Sub ClearCombo(ByVal MyCombo As ComboBox)
MyCombo.Clear
End Sub
Private Sub ClearCombo_Click()
Dim Temp As Control
For Each Temp In Me.Controls
If TypeOf Temp Is ComboBox Then
Temp.Text = ""
ClearCombo Temp
End If
Next
End Sub
Try :
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim i As Integer = DataGridView1.CurrentRow.Index
txttID.Text = DataGridView1.Item(0, i).Value
txttSurname.Text = DataGridView1.Item(1, i).Value
End Sub
To limit your retrieved data from database you use TOP clause in your sql statement.
You can read in this site.
Select TOP 50 * from Customers
Can you show your sql query to retrieve customers from database?
See if this help :
Function pathOfFile(fileName As String) As String
Dim posn As Integer
posn = InStrRev(fileName, "\")
If posn > 0 Then
pathOfFile = Left$(fileName, posn)
Else
pathOfFile = ""
End If
End Function
Call it using Shell() Function :
Private Sub Command1_Click()
Dim myPath As String
myPath = "D:\Dani\result.png"
Shell "explorer " & pathOfFile(myPath)
End Sub
Use looping to read all data.
While (acsdr.Read())
ComboBox2.Items.Add(acsdr("Sections"))
End While
Yes, You need to download the ODBC connector.
Here is the link :
http://dev.mysql.com/downloads/connector/odbc/5.1.html#win32
below is my vb6.0 code. the click command is to save my text and picture. there is no problem for my text. but, i have a problem after saving the picture. the picture can be saved but it is not availabe for preview. is there any fix for this ?
To save picture in PictureBox you should use SavePicture() function :
Dim namefile2
namefile = App.Path & ("/" & Text1 + Text2) & ".bmp"
SavePicture Picture1.Image, namefile
Good. :D
Don't Forget to mark this thread as Solved.
See if this helps :
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
Unload Me
End If
End Sub
like this ?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Enabled = False
ComboBox1.Enabled = False
End Sub
I don't get what you want to exactly.
Please more specify.
You're Welcome. :D
Don't forget to mark this thread as Solved.
Why you don't put it in one form_load?
Make a procedure or function for each code and call it on form_load.
Private Sub waveform_picture_code ()
'waveform picture code
End Sub
Private Sub rfid_code ()
'rfid code
End Sub
Private Sub Form_Load()
waveform_picture_code
rfid_code
End Sub
What you mean two form load work together? these two from load are coming from same Form or different Form?
You can set radio button checked as True in Radio button properties.
Or you can set it manually :
RadioButton1.Checked = True 'RadioButton1 set as default
Combobox1.SelectedIndex = 0 'First item of combobox set as default
See if this help.
This following code will merge multiple text files into one file :
Add reference : Microsoft Scripting Runtime
Private Sub ConcatenateFiles(ByVal ResultFile As String, ByVal Separator As String, ParamArray SourceFiles() As Variant)
Dim FSO As New FileSystemObject
Dim fsSourceStream As TextStream
Dim fsResStream As TextStream
Dim sSeparator As String
Dim i As Integer
On Error Resume Next
' create a new file
Set fsResStream = FSO.OpenTextFile(ResultFile, ForWriting, True)
' for each source file in the input array
For i = 0 To UBound(SourceFiles)
' add the separator first (replacing the special tag for the file path)
sSeparator = Replace(Separator, "#FilePath#", SourceFiles(i))
fsResStream.Write sSeparator & vbCrLf
' open the file in read mode
Set fsSourceStream = FSO.OpenTextFile(SourceFiles(i), ForReading)
' add its content + a blank line to the result file
fsResStream.Write fsSourceStream.ReadAll & vbCrLf
' close this source file
fsSourceStream.Close
Next i
fsResStream.Close
End Sub
Private Sub Command1_Click()
' Example:
ConcatenateFiles "D:\res.txt", "------ NEW FILE: #FilePath# ------", "D:\1.txt", "D:\2.txt", "D:\3.txt"
End Sub
That works! Thanks, but your other code never worked. ( the first post)
You're Welcome. :D
Don't forget Mark this thread as Solved.
You are missing an
End If
after line 9
wow..really an eagle eyes :D
Line 341 is causing the error:
that this code
Document.SelectionFont = New System.Drawing.Font(fontSelection.Text, Document.SelectionFont.Size, Document.SelectionFont.Style)
In your first post, you have two comboboxes for Font name and font size.
You said that you want to select a font size from combo box and apply it to richtextbox. But i didn't see it in your code. Did you tried my code?
Document.SelectionFont = New Font(ComboBox2.SelectedItem.ToString, CInt(ComboBox1.SelectedItem.ToString), Document.SelectionFont.Style)
It cause your "rsLibrary" is not defined.
Try this :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim btn As Control
For Each btn In Me.Controls
If TypeOf btn Is Button Then
btn.ForeColor = Color.Blue
End If
Next
End Sub
Try this :
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
RichTextBox1.SelectionFont = New Font("Tahoma", CInt(ComboBox1.SelectedItem.ToString), RichTextBox1.SelectionFont.Style)
End Sub
You're welcome. :D
Don't forget to mark this thread as solved.
Your code is fine. you just need to hide textboxes when form load. So, when your checkbox checked it will be visible :
private void Form1_Load(object sender, EventArgs e)
{
textBox4.Visible = false;
textBox5.Visible = false;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
textBox$.Visible = true;
textBox5.Visible = true;
}
else
{
textBox4.Visible = false;
textBox5.Visible = false;
}
}
An example :
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim i As Integer = DataGridView1.CurrentRow.Index
With DataGridView1
If DataGridView1.Item(0, i).Value = "1" Then
textbox1.text="hello"
End If
End With
End Sub
It because there is no SubItems(3) in your listview..
And why you show Owner ID twice in all of your codes?
modified as following "
Set lst1 = lvStudentInfo.ListItems.Add
With lst1
.Text = rs!Owner_ID
.SubItems(1) = rs!Owner_Name
.SubItems(2) = rs!Owner_Address
End With
when i click on the command botton then it will show a
Run time error 52
if we delete this line to my coding
Err.Raise 52
then it will show Message (Msgbox "File recycled")
but cannot delete my file
please send me again code here is some problem so please tell me
what's wrong
what i do ?
Thanks
I'm sorry, I forgot to mention you to add reference.
Project-> Reference -> Microsoft Shell Controls and Automation
Also make sure that your files is exist.
You're Welcome. :D
Dont forget to marh this thread solved.
Thanks Jx man
i am very thanks full to you.
you solve my problems many time. so Thanks you are a Genius.
Thanks alot
You're Welcome :)
Don't forget to mark this thread as solved. It will help another members who has same problem like you.
Thank you.
Oh wait! i was not aware of this :-)
Thank you! let me try and see how it works!
Thank you again
Okay. Try it and give a feedback.
If you already managed it then post your code and mark this thread as solved.
It will help another member who has same problem like you. :)
Thank you.
Okay since you need to copy-paste text in textbox 2, then i rewrite this code.
I assume you have 3 textboxes and 1 listbox to join all text.
Try this :
Private Sub Command2_Click()
Dim myParas As Variant
Dim i As Integer
myParas = Split(Text2, vbNewLine)
Dim a() As String
a = Split(Text2, vbNewLine)
For i = 0 To UBound(myParas)
List1.AddItem Text1.Text & a(i) & Text3.Text
Next
End Sub
what you mean exactly?
you want to use textbox instead of listbox?
See if this helps :
Private Sub EnumFolders(fld As Object)
Dim oShell As Object, fldItem As Object
Dim i As Long
On Error Resume Next
Set oShell = CreateObject("Shell.Application")
For Each fldItem In fld.Items
If fldItem.IsFolder Then
Call EnumFolders(fldItem)
End If
list1.AddItem fld.GetDetailsOf(fldItem, 0)
Next
Set fldItem = Nothing
Set fld = Nothing
Set oShell = Nothing
End Sub
Private Sub Command1_Click()
Dim oShell As Object
Dim oRecycler As Object
Set oShell = CreateObject("Shell.Application")
Set oRecycler = oShell.NameSpace(10)
EnumFolders oRecycler
End Sub
See if this helps :
API Declare :
Option Explicit
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SILENT = &H4
Private Sub ShellDeleteOne(sFile As String)
'set some working variables
Dim shf As SHFILEOPSTRUCT
'terminate the file string with
'a pair of null charss
sFile = sFile & vbNullChar & vbNullChar
'set up the SHFile options
With shf
.wFunc = FO_DELETE 'action to perform
.pFrom = sFile 'the file to act on
.fFlags = 0& ' Delete permanent
.fFlags = .fFlags + FOF_NOCONFIRMATION ' No confirm to delete
.fFlags = .fFlags + FOF_SILENT
End With
'perform the delete
Call SHFileOperation(shf)
End Sub
Delete File :
Private Sub Command1_Click()
Call ShellDeleteOne("D:\junk.txt")
End Sub
Delete Folder :
Private Sub Command1_Click()
Call ShellDeleteOne("D:\junk")
End Sub
Delete All Files (folders n files) in folder junk
Private Sub Command1_Click()
Call ShellDeleteOne("D:\junk\*.*")
End Sub
Set KeyPreview as True on form properties.
Then add this following code :
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'make sure KeyPreview is True on Form Properties
'On Error Resume Next
Select Case KeyCode
Case vbKeyUp
MsgBox "Up"
Case vbKeyDown
MsgBox "Down"
Case vbKeyLeft
MsgBox "Left"
Case vbKeyRight
MsgBox "Right"
End Select
End Sub
See if this helps :
Private Sub Recycle2(ByVal FQFileOrFolder As String)
'Late bound.
Dim Delim As Integer
Dim FItem As Object
Const ssfBITBUCKET = 10
Delim = InStrRev(FQFileOrFolder, "\")
With CreateObject("Shell.Application")
For Each FItem In .NameSpace(Left$(FQFileOrFolder, Delim - 1)).Items
If Not FItem.IsLink Then
If UCase$(FItem.Name) = UCase$(Mid$(FQFileOrFolder, Delim + 1)) Then
.NameSpace(ssfBITBUCKET).MoveHere FItem
Exit Sub
End If
End If
Next
End With
Err.Raise 52
End Sub
Private Sub Command1_Click()
Recycle2 "D:\File.txt"
Msgbox "File recycled"
End Sub
I assume you use listbox for all controls :
You can use '&' ampersand sign to concatenate all items with same index for every listbox.
See this following code :
Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
List4.AddItem List1.List(i) & List2.List(i) & List3.List(i) ' add items in list 1,2,3 to list 4
Next i
End Sub
See if this help.
Add a timer, set interval to 1000 (or you can assign as you needed)
And use this following code :
Private Sub Timer1_Timer()
Label1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
Well, you need to know what conditions when you have to send sms automatically.
If you already know it then use timer control to check the conditions and send a sms when you get same condition.
thanks, it's help me...
@ jx man, how about using ActiveXpertsToolkit ...???
is that work like sms libx..???
You're Welcome, Dude
Then please mark this thread solved
See this following code :
For i As Integer = 0 To ListBox1.SelectedIndices.Count - 1
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Next
Or you use this too :
Do While (ListBox1.SelectedItems.Count > 0)
ListBox1.Items.Remove(ListBox1.SelectedItem)
Loop