|
-
Nov 7th, 2001, 02:56 PM
#1
Thread Starter
Lively Member
Adding indexes with VB code
If someone could help me out I would really appreciate it. I need to add 2 indexes to a table in an MS Access DB. I have to write a separate program that will check an (already existing) INI file to see if the indexes have already been added. If they haven't, I need to add the indexes, to the table, and edit the INI file so that it shows that the indexes have been added. One last question, since this program won't really need a GUI, is there a way I could create this program without using a form?
-
Nov 7th, 2001, 03:34 PM
#2
You need something from which to run your code. You could set the visible property to false, unless of course, your code returned an error. I'd assume you would want to know what the error was, so then you could set visible to true. Anyway, thats your call.
Here is some sample code to write to and read from, and InI file:
VB Code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
Dim Ret As String, NC As Long
'Write the setting to the file (c:\test.ini) under
' Project1 -> Keyname
WritePrivateProfileString App.Title, "KeyName", "This is the value", "c:\test.ini"
'Create a buffer
Ret = String(255, 0)
'Retrieve the string
NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
'NC is the number of characters copied to the buffer
If NC <> 0 Then Ret = Left$(Ret, NC)
'Show our string
MsgBox Ret
'Delete the file
Kill "c:\test.ini"
End Sub
-
Nov 7th, 2001, 03:49 PM
#3
-= B u g S l a y e r =-
Re: Adding indexes with VB code
Originally posted by PedroDePacos
... One last question, since this program won't really need a GUI, is there a way I could create this program without using a form?
yes, u can remove the default form 1, then add a module.
in the module create a sub called Main.
Make Sub Main u'r startup routine (in the project properties... see picture)
Add the code needed in Sub Main, and compile it.
any errors can be shown using a msg box.
-
Nov 7th, 2001, 04:03 PM
#4
Thread Starter
Lively Member
Thanks alot for the help, it came in very handy. How about the code to add the indexes? Could you give me push in the right direction? Thanks Again!
-
Nov 7th, 2001, 04:31 PM
#5
-= B u g S l a y e r =-
yes, if u tell me a bit more about the indexes.
-
Nov 7th, 2001, 04:47 PM
#6
Thread Starter
Lively Member
I need to add 2 indexes to one table, both indexes are based on
a different column. Is this the info you need?
-
Nov 7th, 2001, 05:02 PM
#7
Thread Starter
Lively Member
Thanks for all your help, I figured it out and it works like a charm.
This forum is the best and the help is unbelievable! I didn't even
get this quality of help at college.
Thanks Again!!!
-
Nov 8th, 2001, 01:14 AM
#8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|