@brentbret29 -
Advertising? Hmmmm ..
@brentbret29 -
Advertising? Hmmmm ..
I'm happy I could help.
I'm not going to change things just to be changing them. It works fine as-is. If someone else wants to change it to suit themselves, please do.
If you'll notice, the function -
retassoc(fn As String, fpath As String) As String
is asking for strings. If you pass strings to the function it will accept them as strings and go find the file association. If you pass something other than strings to the function .. it won't work. Please notice also that the function returns a string.
I was going to stay out of this, but I see too many ways being described to do the same thing.
The code I posted earlier goes into a module. All of it. As is.
Elsewhere in a program I fill a listbox with the path information of the files I might want to open in their native application. The path information is stored in an MS Access table, or an sql server table, or a MySQL table, or whatever other place you might want to keep them.
I named my listbox "ListView1" (vb default name)
To populate the Listbox I used this. The path information is stored in an MS Access database:
Function popList()
' populates the listview control
Dim sql As String
dim x as integer
' the next line builds the sql statement and adds the user id to the where clause so each user can only see their own documents.
sql = "select tblDocs.docName, tblDocs.docPath, tblDocs.id from tblDocs where clientid = " & getClientID(ActiveClientName)
'
Call opnDB(Me) ' this line just opens a connection to the database.
Set rs = db.OpenRecordset(sql)
ListView1.ListItems.Clear
ListView1.View = lvwReport
rs.MoveFirst
x = 1
With ListView1.ColumnHeaders
.Clear
.Add , , "Document Name", 4000
.Add , , "Document Path", 7000
End With
Do Until rs.EOF = True
With ListView1.ListItems
.Add , , rs!docname
End With
rs.MoveNext
Loop
rs.Close
Set rs = db.OpenRecordset(sql)
Do Until rs.EOF = True
With ListView1
' Add a value to the second column …
I'm going to assume that everyone knows more than I do about this and keep quiet about it ...
Basically you call the Function LoadUserFile(ByVal FN2Load As String) and hand it the full path to the file you want to load.
(like this)
Call LoadUserFile("D:\Documents\MB.accdb")
Think about it. There's a lot you can do with this ...
:)
what's a "haqqulibad" anyway? Do I need to repent?
ykbks needs to visit the microsoft website. That's where I foung the tools to create my original functions ..
If you're looking for a 'one-liner' there is none ..
You should read up on the "GetVolumeInformation" API function.
Let me think about that ..
How about -
dim sql as string
sql = "select tablename.* from tablename limit 5"
' other things you'll need are defined elsewhere in your program
Now, you'll need to add the code that connects to mysql, then open the recordset and show the results to the user. There are About 2,070,000 results returned(0.12 seconds) for this question in Google.
:) it's been a really slow day ..
Let me know if I can help further
Sometimes what is not said is more important that what is said. Trying to describe a process to a programmer without knowing the common "programmer acronyms" can be a challenge. I usually try to read between the line and try to find what the user really wants, not what it looks like he's asking for. And often it can be done without playing '20 questions' ..
Yes, the code in both links is VB6 code. Neither codepiece is complete. You'll need to customize it to make it do what you need. The code in my link = http://www.daniweb.com/software-deve...-6/code/383557 was pulled from a production program that is able to open any file or document in its' native application. The 'native application' must be installed on the workstation so the file association can be determined. (to open pdf files, you need at least adobe reader)
I try to answer pleas for help for all the above reasons.
Sometimes the 'asker' is a college student wanting you to code a function for them and from what I see in older threads it looks like no one wants to do somebody's homework.
But, if a person honestly needs help with a real-world project and shows an interest in trying to understand the answers given .. that's reward enough. Folks who don't give feedback or just want homework done usually don't get any future questions answered ..
:)
(m)
yes, it is a VB question. Opening a file in its' native application is a common practice. I do it all the time.
Look here for an example - http://www.developerfusion.com/code/278/open-a-fileurl-with-its-default-program/
I use a slightly different method, but the above works ok, too.
here's my way of doing it - http://www.daniweb.com/software-development/visual-basic-4-5-6/code/383557
(m)
Sometimes the simple way works best ..
You can also use 'rmdir' (rd) to delete a file or folder, and 'chdir' (cd) to change the current directory. Yes, these are DOS commands (dos is old! OMG!) but they are still supported in all versions of windows and Visual Basic. These same commands are built in to Linux and other operating systems and work very well.
look here for more - http://en.wikipedia.org/wiki/List_of_DOS_commands
You should mark this thread as "Solved" and pass me the credit. Thanks.
I tried the example on your 'this' link. it causes an error. (line 2, character 8)
I use winxp, and copied the example 'as-is' using the 'all files' option, and named it 'welcome.vbs.
Either I have something missing or the script has an error in it.
here's the script -
Dim speaks, speech
speaks=”John, Welcome to your Computer“;
Set speech=CreateObject(“sapi.spvoice”)
speech.Speak speaks
I always use this when in VB .. it's not as complicated, and if your permissions are ok it works every time..
If Dir("c:\newfolder") = "" Then MkDir ("c:\newfolder")
Have you ever needed to open a file with your VB program?
Here's a way to easily do it. (code copied from an original program written by Mike B)
If the program that uses the file is installed on your workstation, the file will be opened in that application.
I use this a lot in many programs.
:)
Mike
I tried vb 2010 express once and immediately went back to vb6. The example above from microsoft is a vb6 project.
'atemp' is not a vb command.
I think you should look for an example that uses vb2010. A quick google search got me this on the msdn website - http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/487fb2d5-92fd-43f8-8ecd-35e03cf98d49/
It looks almost like the vb6 example ..
You can also look here for vb 2010 code at msdn - http://msdn.microsoft.com/en-us/vbasic/ms789074
here's the working example from the microsoft website. Use it as a starting point to do whatever you need to do with Excel ..
Article ID: 142387 - Last Review: June 30, 2004 - Revision: 4.3
How To Create Excel Chart w/OLE Automation from Visual Basic
=============
Steps to Create Example Program
Start a new project in Visual Basic. Form1 is created by default.
Add a command button (Command1) to Form1.
Add the following code to the Command1_Click event procedure:
Private Sub Command1_Click()
Dim oXL As Object ' Excel application
Dim oBook As Object ' Excel workbook
Dim oSheet As Object ' Excel Worksheet
Dim oChart As Object ' Excel Chart
Dim iRow As Integer ' Index variable for the current Row
Dim iCol As Integer ' Index variable for the current Row
Const cNumCols = 10 ' Number of points in each Series
Const cNumRows = 2 ' Number of Series
ReDim aTemp(1 To cNumRows, 1 To cNumCols)
'Start Excel and create a new workbook
Set oXL = CreateObject("Excel.application")
Set oBook = oXL.Workbooks.Add
Set oSheet = oBook.Worksheets.Item(1)
' Insert Random data into Cells for the two Series:
Randomize Now()
For iRow = 1 To cNumRows
For iCol = 1 To cNumCols
aTemp(iRow, iCol) = Int(Rnd * 50) + 1
Next iCol
Next iRow
oSheet.Range("A1").Resize(cNumRows, cNumCols).Value = aTemp
'Add a chart object to the first worksheet
Set oChart = oSheet.ChartObjects.Add(50, 40, 300, 200).Chart
oChart.SetSourceData Source:=oSheet.Range("A1").Resize(cNumRows, cNumCols)
' Make Excel Visible:
oXL.Visible = …
A good C++ programmer keeps a set of reusable functions in his 'common' folder so he can make a new program by just copying a few of them into the new project, write 6 lines of code to tie everything together, compile and execute.
And I have yet to find something any flavor of C can do that can't be done in VB (including performance). Can a user tell the difference between 10 and 15 nanoseconds?
*grin*
I found an old thread that had never been answered here - http://www.daniweb.com/software-development/vbnet/threads/330981
Basically, the guy was asking how to retrieve database names and/or table names from a MySql database with vb.net. Here's my answer to that. Yes, I still use vb6 because vb.net is not much better and I can do anything I need to in vb6. This function is from a production program I wrote a while back.
I looked all over Google to see if I could find a better way to do it but the examples I found were 'college level' and not real world code, so I wrote my own. This function returns a recordset just like any other recordset. Once you get the DB Names you can do whatever you want.
I haven't defined everything here .. the code calls external functions that open or close a connection and the ADODB and ADO recordset are defined elsewhere. But if you work with Visual Basic you should already know how to set up an ADO Connection and recordset. If not, ask your professor. He'll send you to Microsoft's website so you can look it up. *grin*
To see tablenames set the sql to - sql = "show tables in " & dbname & ";"
where dbname is the name of the database to enumerate.
Want to see the field names too?
set sql to - sql = "show columns from " & tbl & …
C# is designed for the college crowd so they can learn enough about programming to be able to move up to C++ ..
Never had that happen. But I would try ctrl/Z to see if it put everything back.
How about an application that will read and write to an ini file in the same format as windows uses?
In my case I always store the path to the picture and keep the actual picture somewhere else (maybe on a different server). sql server gets 'bloated' when you store pictures in it.
windows explorer 'stalls' because of it's timeout duration. Windows Explorer is at the mercy of the devices it's trying to list. If any of those devices experience a delay in returning the information that Windows Explorer is asking for, you'll notice a delay.
Disconnecting network drives and perhaps unplugging other devices could at least give you a clue as to which device is contributing to the delay.
So .. no matter whos' File Manager is used, if it asks for information from a device that takes it's time answering (or doesn't answer at all) there will be a delay.
Another reason for a slow file manager might be that your PC has so much junk and spyware on it that explorer chokes. Do a cleanup.
Now, write a file manager with a timeout configuration value that's user adjustable.
:)
Use "LoadPicture(path_to_picture)
Enumerate field names in a recordset
Function getfieldnames(mytable As String)
Dim fld As Field
Dim dbf As Database
Dim rs As Recordset
Dim sql As String
Set dbf = CurrentDb()
Set rs = dbf.OpenRecordset(mytable, dbOpenDynaset, dbSeeChanges)
sql = ""
For Each fld In rs.Fields
sql = sql & fld.Name & ","
Next
getfieldnames = Left(sql, Len(sql) - 1)
dbf.Close
rs.Close
End Function
here's one I use sometimes. It gets the names of all user tables in the database and puts them in a comma delimited string. You can modify it to do whatever you want.
Function GetTableNames() As String
Dim tdf As TableDef
Dim dbf As Database
Dim sql As String
Set dbf = CurrentDb()
sql = ""
For Each tdf In dbf.TableDefs
If Left(tdf.Name, 4) <> "msys" Then
sql = sql & tdf.Name & ","
End If
Next
GetTableNames = Left(sql, Len(sql) - 1)
dbf.Close
Set tdf = Nothing
End Function
programming 101
Can you copy/paste it into notepad then do a save or saveas?
Flat Rate shipping causes 1) customers to go elsewhere because your rates are too high, or 2) you lose money because your rates are too low. At best, flat rate shipping is a gamble.
Better to get an actual shipping charge from FedEx, UPS, or the Post Office. The FedEx module I use is called "fedex1.php". It's provided by FedEx. It gets a shipping charge directly from Fedex and presents it to me. I just add it to the customers order.
admin said I should introduce myself ..
Hi everyone!
I'm a software developer and uhh .. I develop software.
*grin*
"MS-Access gives error like MS Access encounter serious problem and needs to be closed."
This almost tells me that he's using MS Access, not Visual Basic. In Access he can use ado in code either behind a form or in a module ..
I use OSCommerce for my sites and have FedEx shipping available. FedEx has an API that gets installed into oscommerce and gives me shipping charges based on the weight (in pounds) of what I sell.
Tax calcs are also built in. I charge tax in my home state only.
I use live chat on my site, mostly for customers who need installation help. Everyone likes it ..
:)
I usually use DAO with MS Access, and I have several DAO enabled programs that read/write data in a MySQL database .. but to use ADO you need the "Microsoft ActiveX 2.7 Library" included.
As long as I have C++ installed on my workstation, it will not die ..
Most E-Commerce 'solutions' are based on OSCommerce open source code