jhai_salvador 48 Junior Poster

Well, as what the error said, make sure your database path is valid. Anyway, can you post your database connection code?

jhai_salvador 48 Junior Poster

I want to show a form and on top of that form I want to show another form. I want to be able to access any of the two forms (so I can't use vbmodal)

Then you should use SetWindowPos API. Check this out

http://www.ex-designz.net/apidetail.asp?api_id=192

jhai_salvador 48 Junior Poster

Well you have to create setup file for your compiled app so that all the controls and DLL you use in your application will also be installed in another machine.

Google VB6 Package and Deployment wizard because you can use this application to create setup packages for your vb6 application.

jhai_salvador 48 Junior Poster

You don't have to unload it, as what the person said above me, you can set the 2nd form as Modal when SHOWing.

Private Sub Command1_Click()
   frm2.Show vbModal, Me
End Sub
ulrichrandom commented: thank you very much. i will try this. Follow up question. after i'm done with frm2, how do i get back with the previous form? do i use unload me or something? thank you again. :) +0
jhai_salvador 48 Junior Poster

We plan on doing lots more contests in the future ... we're just getting our feet wet and we'll learn what works and what doesn't as we go along! :)

Well, I hope next time we can just have a programming contest and submit a fully working application and not just a code. :D

jhai_salvador 48 Junior Poster

Well, for me, its YES.
But you can only write application on VB6 for Windows OS. If you want a cross flatform application you can try RealBasic. If you want to write for android, then try basic4android

jhai_salvador 48 Junior Poster

My pleasure to help you. Please mark the thread as SOLVED.

jhai_salvador 48 Junior Poster

This is what Im using on my crystal report 8.5.

Reports are created and connected via odbc so database location can be easily change.

Dim crxTable As CRAXDRT.DatabaseTable
Dim mReport As CRAXDRT.Report

For Each crxTable In mReport.Database.Tables

 '* Use to Connect via ODBC,
 '* crxTable.SetLogOnInfo(pServerName As String, [pDatabaseName], [pUserID], [pPassword])

 crxTable.SetLogOnInfo "ODBCName", "db.mdb", "admin", "passwordgoeshere"
 DoEvents
Next
jhai_salvador 48 Junior Poster

Aw, sorry, did not notice that when i remove some codes in prompt_err function.

Anyway, you can just ignore it since the code that im really sharing is CompactAccess function.

My other code snipped about prompt_err function can be seen here: http://www.daniweb.com/software-development/visual-basic-4-5-6/code/336042/easy-code-debugging-prompt_err-function

Thanks,

jhai_salvador 48 Junior Poster

Hi!

This is my submission for code snippet contest.
I also posted this code to help other members on how they can use compact & repair their MS Access Database within Visual Basic 6.0.

You also need to add Microsoft Jet and Replication 2.6 in your project reference.

To use, add the snippet in Module;

Once you have added it to the module just call CompactAccess with database location and its password like this;

Call CompactAccess("C:\Database.mdb", "12345")

I also attached a sample project on how you can use it, just check it out.

Click Here

Please note that the database should be close before compacting it, else it will not work.

Thanks,

Dani commented: Good luck! +0
AndreRet commented: Nice Snippet Jhai +12
jhai_salvador 48 Junior Poster

Don't you have the complete source code of that exe?..

jhai_salvador 48 Junior Poster

Why not create your own?.. use textbox, a button, and listview..

Listview should be hidden, then when the button is press, listview will be visible. then once item is selected or listview lost focus, then hide the listview again.

jhai_salvador 48 Junior Poster

How about using Property GET/Let?

Put this code in your form (General Declaration Section)

' Variable to hold 'VarValue' property value
Private refVarValue As String

Public Property Get VarValue() As String
   VarValue = refVarValue
End Property

Public Property Let VarValue(ByVal strValue As String)
   refVarValue = EnuValue
End Property

Then, when you call the form where you put the code above (ex, Form1)

Form1.VarValue = "Your String goes here"
Form1.Show

'Then on form1 load event, put this code
Private Sub Form_Load()
   Debug.Print refVarValue
End Sub

Try to run it and see what happens.

jhai_salvador 48 Junior Poster

Its the same as sharing a folder in a network.

see http://support.microsoft.com/kb/308582

Anyway, what database are you going to use?.. M$ Access? sql server?

jhai_salvador 48 Junior Poster

Yes, your on the wrong section, post it on vb.net section. :D

EDIT:
Make sure your pen drive is not infected, try to see your pen drive if there are any hidden folders.

jhai_salvador 48 Junior Poster

ISP IP? or your IP Address?

You can use is use M$ winsock control; Try it,

put winsock on form, then add this code in form load event;

   Debug.Print Winsock1.LocalIP

then check your immediate window, you will see your IP Address (Same address that you can see on http://www.whatismyip.net/)

lmpush commented: Thanks for your reply. As per this coding it is showing the local machine ip only. i want to know my internet service provider IP Address. +0
jhai_salvador 48 Junior Poster

You can also try the search box. I think this is already solved many times. hehe

jhai_salvador 48 Junior Poster

@Abe, sir andre is right, we need to declare variables even if vb6 accept and run without declaring any variable. Try to put this code on the General Declaration area so you will not forget to declare your variables :D

Option Explicit

You can also make vb6 automatically adds option explicit by going to Tools > Options > Editor Tab > then tick "Require Variable Declaration" > Ok.

jhai_salvador 48 Junior Poster

In the design time, you must make your form Splash Border Style property to None so it cant be moved out or minimized. You can also show your splash as modal window like this

splash.show vbModal, Me

But make sure you have a timer event make your splash form unload automatically, or unload when user click on the splash screen form.

Happy coding...

jhai_salvador 48 Junior Poster

Heres a sample on how to add a record to database.

Dim rstInfo As New ADODB.Recordset
Dim SQL as String
SQL = "SELECT * FROM List"
rstInfo.Open SQL, cn, adOpenStatic, adLockOptimistic
rstInfo.AddNew
rstInfo!CustomerName = txtName.Text
rstInfo!ContactNumber = txtContact.Text
rstInfo!Date = txtDate.Text
rstInfo!TimeStart = txtStart.Text
rstInfo!TimeEnd = txtEnd.Text
rstInfo!Event = txtEvent.Text
rstInfo!PossibleNumberofGuest = txtGuest.Text
rstInfo!Comment = txtComment.Text
rstInfo.Update
rstInfo.Close
Set rstInfo = Nothing

Happy coding :D

jhai_salvador 48 Junior Poster

:D okay. Thanks

jhai_salvador 48 Junior Poster

If you want your assignment to be done completely then you can post your project at vworker.com. This will cost you but if you really need a complete source then try it! ;)

Post a Project for me Then I will be glad to give you a complete source ;)

jhai_salvador 48 Junior Poster

:D my given samples should work with your needs so you just need to analyze and understand it.

jhai_salvador 48 Junior Poster

Just remember that Sendkeys will NOT work in Vista or Win7.

I took the entire long route which works wonders. If someone knows what they are doing, they can still use task manager....

This will disable it until the application is closed.

Public Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long



x = SystemParametersInfo(97, 1, CStr(1), 0) 'Disable Ctrl+Alt+Del Keys combination
'Use as in --->>>
If KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ Or KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= vbKey0 And KeyAscii <= vbKey9 Or KeyAscii = vbKeyBack Then
        'do nothing
    Else
        KeyAscii = 0    'Disable all other key strokes
    End If

Will that code work on windows vista and windows 7? It can also disable other keys like ALT-Tab or ALT-ESC ?

jhai_salvador 48 Junior Poster

Yes, just like my 2nd Post. :D

jhai_salvador 48 Junior Poster

Why not use my err function in the code snippet? so it will be easy to locate the error line.

Make sure that your recordset is closed before you open it again.

if RecSet.State = AdStateOpen Then
RecSet.Close
End If
jhai_salvador 48 Junior Poster

If you don't know much about sql, then try the other way around like storing record from a variable.

Dim UserType as string 

UserType = rs!UserType 
if UserType <> "Admin" Then
   rs.Delete
End If

Heres a code of the delete using sql.

DBLink.Execute "Delete From Users Where ID = " & lvwUser.SelectedItem.Text & " AND UserType = 'Administrator'"
DBLink.Execute "Delete From Users Where ID = " & lvwUser.SelectedItem.Text & " AND UserType = 'User'"
jhai_salvador 48 Junior Poster

How about showing your effort first?

You can check out this code snippet of mine to see how I manipulate the strings.

Here

jhai_salvador 48 Junior Poster

You can use loop then use the Mid function and Iterate through the whole string.

jhai_salvador 48 Junior Poster

Your Welcome! Glad to help fellow Filipino. :D

jhai_salvador 48 Junior Poster

Don't know what is wrong with it but its working in my code. Make sure your DatabaseLocation is your full database path.

Private Sub Form_Unload(Cancel As Integer)
    Call SetAttr(DatabaseLocation, vbReadOnly)
End Sub
jhai_salvador 48 Junior Poster

Add the first code in line 11 so it will be set to normal. Then the second code will just be before you exit the application or before calling the END keyword that would terminate the application so that it will return in Read Only Mode.

jhai_salvador 48 Junior Poster

:D This is just a trick that might work for # 2. Just follow this steps

1. Right click your Database (*.mdb) > Properties > Tick Read-Only

This will not allow user to make any changes in your database. simple trick right? :D

2. In you VB6 code, use the SetAttr function to set the database to normal (remove read only property)

Use this code to make your database back to normal. Use it before you connect.

Dim DatabaseLocation as String
DatabaseLocation = "D:\SilentProject Softwares\Property and Sales Information\Database\Database.mdb"
Call SetAttr(DatabaseLocation, vbNormal)

Now use this code to make your database as read only. Use it before terminating your application.

Dim DatabaseLocation as String
DatabaseLocation = "D:\SilentProject Softwares\Property and Sales Information\Database\Database.mdb"
Call SetAttr(DatabaseLocation, vbReadOnly)

Hope this solves your problem. :D

jhai_salvador 48 Junior Poster

Your welcome! :D now mark this thread as solve...

jhai_salvador 48 Junior Poster

You can refer to this previous thread of mine.

Previous Thread

Hope its help.

jhai_salvador 48 Junior Poster

Just repeat the Replace Function.

Dim A as string, B as string 
A = "@AA@BB@CC@DD@EE@FF@GG@HH@AB"
A = Replace(A, "@BB", vbNullString)
'etc
jhai_salvador 48 Junior Poster

thats easy. Use Replace function.

Dim A as string 
A = Replace("@AA@BB@CC@DD", "@BB", vbNullString)

it will return @AA@CC@DD

Hopes this solves your problem.

jhai_salvador 48 Junior Poster

Your welcome! :D And Remember to mark your thread as Solved when your question is answered.

jhai_salvador 48 Junior Poster

Haha :D but its a good solution so thats just fine.

jhai_salvador 48 Junior Poster

On Line 22, I think it should be like this.

cbodept.AddItem oRs!Office
jhai_salvador 48 Junior Poster

1. Please read our forum rules :D
2. ID Number field includes space, so you should enclosed it with square brackets so it can be identified by your query as a whole field.
3. Adodc1.Refresh and Adodc1.Recordset.EOF will be fix when you fix the first error.

Private Sub Command1_Click()

Adodc1.RecordSource = ("select * from Student where [ID Number] ='" & Text1.Text & "'") 
Adodc1.Refresh 
If (Adodc1.Recordset.EOF = False) Then  
    If Adodc1.Recordset.Fields("Password") = Text2.Text Then
    MsgBox ("Successfully Logged-in"), vbInformation, "Log-in"
    Homepage.Label1.Caption = Text1.Text
    Homepage.Label2.Visible = True
    Login.Visible = False
    Homepage.Visible = True
    Else
    Val (X) + 1
    MsgBox ("Wrong Log-in information"), vbInformation + vbRetryCancel, "Log-in"
    End If
Else
    Val (X) + 1
    MsgBox ("Wrong Log-in information"), vbInformation + vbRetryCancel, "Log-in"
End If

Also, avoid using field name with spaces to prevent this kind of error. Name it like this ID_Number instead of using spaces on it.

Mark the thread as solve if this solves your problem :)

jhai_salvador 48 Junior Poster

Forgot to remove it :D

here it is Again w/o the exe....

peter_budo commented: Good job +16
jhai_salvador 48 Junior Poster

ohh.. okay.. then I'll just make it as the source. :)

------------
Source code is added in the attachment. :) Hope you'll like it.

jhai_salvador 48 Junior Poster

I did not get that error when I try it myself.

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
   SendKeys "{tab}"
End If
End Sub
jhai_salvador 48 Junior Poster

Your Welcome! ;)

jhai_salvador 48 Junior Poster

Hi! Please visit my code snippet thread.

Easy Code Debugging - prompt_err Function

Then add line number in your code like this.

Private Sub cmdPrintSel_Click()
On Error GoTo errHand

1 Call Con("Database.mdb")
2     
3     RecSet.Open "Select Payroll.EM_ID, Payroll.EM_Name, Payroll.EM_Dep, Payroll.Monthly_Rate, Payroll.dDate, Payroll.xBonus, Payroll.xOT, Payroll.GSIS, Payroll.PH, Payroll.InTax, Payroll.Others, Payroll.absences, Payroll.Advances, Payroll.NetPay From Payroll where EM_ID =" & lvwInfo.SelectedItem.Text & " Group By Payroll.EM_ID, Payroll.EM_Name, Payroll.EM_Dep, Payroll.Monthly_Rate, Payroll.dDate, Payroll.xBonus, Payroll.xOT, Payroll.GSIS, Payroll.PH, Payroll.InTax, Payroll.Others, Payroll.absences, Payroll.Advances, Payroll.NetPay having Month(dDate)='" & Month(dt1.Value) & "' And Day(dDate)='" & Day(Me.dt1.Value) & "' And Year(dDate)='" & Year(dt1.Value) & "' Order By Payroll.EM_ID;", DBLink, adOpenKeyset, adLockPessimistic
4     
5     Set drtSel.DataSource = RecSet
6     drtSel.Show 1
7     
8 RecSet.Close
9 DBLink.Close


Exit Sub
errHand:
   prompt_err Err, "Form1", "Update_Details"

End Sub

I have use the application that I created to add line numbers with the code (It is also attached in my code snippet).

After that, try running it and you can locate the error more easily. Thanks

jhai_salvador 48 Junior Poster

Hi! I just want to share you this code snippet of mine which I use always in my application.

This code snippet will help you debug your code easily. It will also help you locate where the error occurred and it also create an Error log located on your project directory.

In Visual Basic, Erl, a Visual Basic (undocumented in Visual Basic 4, 5, and 6 but present in all versions of Visual Basic thus far) "global variable," gives you access to the line number of any erroring line of code. So by using line numbers and by using Erl in your error handlers, you can determine which line of code erred-wow! What happens to Erl if you don't use line numbers? it will always be 0.

More details

You can use the attach file that I created my self to Add and Remove Line Numbers in your code.

You can use the prompt_err function with line number in your code like this.

Sub Update_Details()

On Error GoTo errHand

1 If rs.EOF = False Then
2    MessageBox ErrorHere
3 End If

Exit Sub
errHand:
   prompt_err Err, "Form1", "Update_Details"

End Sub

Try the function and see the result. Hope you like this one. Thanks.

jhai_salvador 48 Junior Poster

I also found something on the net where you can download Text-to-Speech Voices that you can install on your computer.

Haven't tried it, but I hope the link will work.

Click Here

jhai_salvador 48 Junior Poster

This is my code with Microsoft Speech Object Library as my reference

Dim Voice As SpVoice

Set Voice = New SpVoice

'* This will display available voice in VB6 Immediate Window from your computer
Debug.Print Voice.GetVoices().Count

'* This will change the voice
Set Voice.Voice = Voice.GetVoices().Item(0) '* Index 0 = Voice Count

Voice.Speak Text1.Text, SVSFlagsAsync

I only have Microsoft Sam installed on my computer, so Voice Count is just 1.

Hope this Helps

jhai_salvador 48 Junior Poster

I always use Google Chrome in web creating scrapper.

If possible, how about providing the website address so we can analyze the site ourself?...