choudhuryshouvi 33 Posting Pro

what did you mean by login file stored online?

look, the scripts i have provide here can be applicable on offline textfiles only. if you wish to try to access from an online source then the programming technique is completely different.
now the access technique depends on the type of connectivity you are using. if you use a local area connection network then your login.txt file must be placed into a server and all client nodes must have sufficient priviledge to access the server.
now if you wish to access this file from a remote server such as a webserver you must write an asp script for that. simply writing code from your vb6 application to connect to the text file won't work.

infact, in such a case textfiles are useless. using databases is always preferable in this context.

and one more thing,
all scripts that i provided here are 100% correct and running smoothly. they are all tested. now if any one of these failes to run on your machine that doesn't mean that the code is wrong. you should have to modify the code to suit your program. if its possible for you upload your existing application here so that i can check it on my machine.

by the way, i have checked the link you provided. sorry to say but its a broken link.

now the decision completely depends upto you. but you must not blame on code/scripts submitted …

choudhuryshouvi 33 Posting Pro

okk....

choudhuryshouvi 33 Posting Pro

listen carefully my frnd,
Microsoft Activex Data Objects is a reference not a component or control. so it won't be added into the toolbox. each control you use on your vb6 form adds a reference to your project. now if you add an ADODC control on your form it will add the same ref. on your project too. to see this, just add an ADODC control from your component list and now go to Project->References. there you will see Microsoft Activex Data Objects has been added to your project reference list.

i'm telling you again plz read previous replies ten times before you post a reply.
in my previous replies several times i have said that this code doesn't require any control/component to be added on your form. it is using a reference and for that adding MS ADO is enough.

look into the code very carefully. there is a statement Dim gcn as New ADODB.Connection. this is a global variable which is nothing but an instance of ADODB Connection object. so to use this vars or accessing ADO methods/functions inclusion of this reference is very much important. otherwise you will face compilation errors.

hope you'll understand and approach to right direction this time.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

There is so such control in the Components... Microsoft Active X Plug in ..Is it same as which u r saying?/I m working on 6.0.

absolutely no.
you are in wrong place.

look at your menu bar inside your vb6 IDE. you will find a menu called Project.
inside it there is a command References... goto there,scroll down and add the reference
Microsoft Activex DataObjects ... Library

choose the highest version.

ok....

choudhuryshouvi 33 Posting Pro

you don't require that control you mentioned.

infact, you don't require any data controls from your components list to work with this code. for listview control add this ,
Microsoft Windows Common Control 6.0

regards
Shouvik

choudhuryshouvi 33 Posting Pro

go to the following site :-

http://www.vbexplorer.com

you will get enormous information.

or check out for a link even inside this thread. on top of the page.

choudhuryshouvi 33 Posting Pro

not compulsorily.
but you can use the ADODC control.
but it is not recommended. always use ADODB objects to communicate with your databases.

in the preceding code i gave you, you don't require to have any ADODC control on your form.

ok...
tell me if any more problem arises...

regards
Shouvik

choudhuryshouvi 33 Posting Pro

why this question is raising?

"If u don't want to reply then its's OK."

i think there must be a misunderstanding. i just said you that not only me others can also give you valuable replies. there is no such problem that i don't want to reply you.
its my pleasure to reply you too...

i told that because due to the language you have used in your reply other members can get hurt from it or there a misunderstanding among the members can arise. personally i don't want that to be happened. so that's why i told you that.. hope you will understand...
so don't think like that any more...

ok..

regards
Shouvik

choudhuryshouvi 33 Posting Pro

I think you are a new poster here. so there is something that i want to tell you and you should know this too.

1. before posting any thread please refer to the forum rules.
2. after posting a thread wait for some time to let someone to give you an appropriate reply. look this is a free forum. so everyone is participating here by spending a lot of his/her valuable time. so donot expect any quick reply.
3. before posting any other thread regarding the same topic atleast visit your existing thread to see whether you got any reply or not. don't post the same thread/same question again n again.
4. think ten times before you post a reply as well as a new thread.
5. this is a request please keep this forum clean and well-organized as far as possible.

you have posted three threads with this same topic. please don't ever try to do this again.check your previous threads i have already made some replies there. not only me others might be replied there.

ok....

regards
Shouvik

choudhuryshouvi 33 Posting Pro

the steps you followed for creating the DSN are absolutely correct. but there is no need to create that. it is always recommended that you use a DSN-Less connection. It becomes more faster.

ok...here is a sample connection snippet for you. please note that this code uses DSN-Less connection.
just goto Project->References and add Microsoft Activex Data Objects <Version No.> Library into your project.

[B]''code for making a connection with the sql server database[/B]
Private Sub Form_Load()
Dim gcn as New ADODB.Connection

gcn.connectionstring="Provider=SQLOLEDB.1;Persist Security Info=False;[B]User ID=bs[/B];[B]Initial Catalog=BILLING_SYSTEM[/B]"
gcn.open
msgbox "A connection to the database is now established"
End Sub

[B]''code for retrieving some rows from a table[/B]
Private sub Command1_Click()
Dim rs as New ADODB.Recordset
Dim str as String
Dim li as ListItem

str="select * from branch_details order by branch_id"
rs.open str,gcn,1,2

if rs.Recordcount>0 then
   rs.MoveFirst
   While not rs.EOF()
      with Listview1
         set li=.listitems.add(,,(branch_id))
         li.subitems(1)=rs!branch_name
         li.subitems(2)=rs!address
      end with
      rs.MoveNext
   Wend   
else
   msgbox "No record found." & vbcrlf & "Please add some records."
end if

if rs.State=adStateOpen then rs.close
set rs=Nothing
End Sub

look for the Bolded Parts in the connection string. the first one should be replaced by yours database user name and the second one is by your original database name.

for inserting values from textbox to your sql server database use the following code :-

Dim rs as New ADODB.Recordset

if rs.state=adStateopen then rs.close
rs.open "select * from [B]branch_details[/B]",gcn,1,2
rs.AddNew
rs!branch_id=txtID.text
rs!branch_name=trim(txtName.text)
rs!address=trim(txtAddress.text)
rs.Update
if rs.state=adStateopen then rs.close
set rs=nothing

Msgbox "New record added."
choudhuryshouvi 33 Posting Pro

why are you asking like that?

not only me there are so many experts are here. apart from me they can also give you proper suggestions.

ok... check in your other thread.
i have given a sample code there.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

ok.....that's a separate issue.
in that case your assumption is correct.

i just posted it because you didn't tell that first.

regards
Shouvik

choudhuryshouvi 33 Posting Pro
choudhuryshouvi 33 Posting Pro

ya you got me right

choudhuryshouvi 33 Posting Pro

Secong thing,u have done one error ,to detect an error during the display of the dialog Box, Set the CancelError property of the common Dialog Control to True not False.

why are you trying to display runtime error from your application? will it add extra values to your project? or will it enhance good looks for your application?

never mind but as a programmer/developer every one tries to make bug/error free application. that's the optimum requirement in software development.

must be you are in opposite path!!!

choudhuryshouvi 33 Posting Pro

is there any condition you have in your project that you must use the .Action property?
if yes then there is nothing to say. but if not then why are you using that technique? because using the .Show<Dialog Name> is most preferable than using the .Action method as in the later case you have to remember those numbers. but if you use the former one you don't need to remember anything. each one of them will be available to you just when you call the intellisense.

ok... if you insist so then these are the numbers for your action property :-

for openfile dialog
Action=1
for save as dialog
Action=2
for color dialog
Action=3
for fonts dialog
Action=4
for printer dialog
Action=5

one more thing, regarding the error you just misjudged what i've said. the syntax for error trapping which i gave is for preventing an error to be displayed when an user clicks cancel button of the dialog not to show the error.

if you set CancelError=True and you click the cancel button vb6 will return you the following runtime exception :-

Runtime Error : 32755
Cancel was selected

now if you click on the debug button the compiler will highlight this line (based on which dialog you opened) :-
CommonDialog1.ShowOpen

so in this case you must write an error handler explicitly. now to avoid this from happen you can set CommonDialog1.CancelError = False. for …

choudhuryshouvi 33 Posting Pro

i just can't understand what exactly you are trying to do?

first you posted, you want your program to access a text file where some sort of username and password have been stored. then you will pass a set of username and password from your form's textboxes and your program should check this with corresponding to all the records stored in the text file. now if any of the pairs matches with the textbox values you will give access permission to your user.

secondly you posted, how could you make your program so that when you are creating users it won't accept duplicate username and password. it will only store such a pair which doesn't exist in the textfile.

tell me whether i'm right or wrong?

i have just given you the codes which match your request and i think regarding the issues you posted i gave correct solutions. these codes are tested in my machine and these are working perfectly.

now whatever you said in your last three posts could you please explain it more clearly? i just want a clear explanation in simple and clear english. just tell what exactly you are trying to do?

and one more thing, if its possible plz upload your existing program which you have done so far so that i can test it on my machine and give you most appropriate solutions based on the results generated by your application.

now if you don't wish …

choudhuryshouvi 33 Posting Pro

when you open this forum you can see a Solved word just beside the threads. this signifies that the related thread has been solved. it means the person which started the thread has got an answer for his/her problem/question that he/she posted.

or another way,
when you login using your username and password, you can see there is a link just below the page which is Show Solved Threads. just click this and you can see all threads solved so far.

ok....
bye

regards
Shouvik

choudhuryshouvi 33 Posting Pro

there is no need to use the Action property.

use .ShowColor like

'for color dialog
CommonDialog1.ShowColor
'for print dialog
CommonDialog1.ShowPrinter
'for openfile dialog
CommonDialog1.ShowOpen
'for save as dialog
CommonDialog1.ShowSave

for changing color of the form this line
Form1.Backcolor=Commondialog1.Color
is perfectly ok

and for trapping the error when you press cancel button in the dialog do like this ,

Commondialog1.CancelError=False

hope this helps

regards
Shouvik

choudhuryshouvi 33 Posting Pro

ok....
try this code.
place two textboxes(txtusername,txtpasswd) and a button. no need to create the text file. it will be automatically created.

Dim user As String, pwd As String
Dim duplicate As Boolean

duplicate = False

If Dir(App.Path & "\user.txt") = "" Then
    GoTo adduser
Else
    Open App.Path & "\user.txt" For Input As #1
        Do While Not EOF(1)
            Input #1, user, pwd
            If Trim(user) = Trim(txtusername.Text) And Trim(pwd) = Trim(txtpasswd.Text) Then
                duplicate = True
                Close #1
                Exit Do
            End If
        Loop
    Close #1

    If duplicate = True Then
        MsgBox "username/password already exists."
    Else
adduser:
        Open App.Path & "\user.txt" For Append As #1
            Write #1, Trim(txtusername.Text), Trim(txtpasswd.Text)
        Close #1
        MsgBox "User created."
    End If

    txtusername.Text = ""
    txtpasswd.Text = ""
    txtusername.SetFocus
End If

give me a feedback.
regards
Shouvik

choudhuryshouvi 33 Posting Pro

what exactly are you trying to do?

are you trying to create access forms and reports from your vb6 application?

or,
trying to create forms and reports in access and want to fire those reports from vb6 application?

explain clearly...

choudhuryshouvi 33 Posting Pro

thanks buddy
i didn't ever try to underestimate your code.
that's a great one too.

i just tried to show thats there is an alternate solution too.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

its ok...

always try to maintain the forum rules
it seems like you have now found the thread.
read it and if any more problem you face just post it right there.

choudhuryshouvi 33 Posting Pro

instead of placing the shortcut if you wish to launch your program automatically though coding then you can try the following snippet :-

PLACE THIS CODE IN A MODULE

Option Explicit

Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" _
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long

Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey _
As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData _
As Any, ByVal cbData As Long) As Long

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Public Const REG_SZ = 1
Public Const HKEY_LOCAL_MACHINE = &H80000002

Public Sub IncludeAtStartup(hKey As Long, strPath As String, strValue As String, _
strdata As String)

Dim keyhand As Long
Dim r As Long

r = RegCreateKey(hKey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
r = RegCloseKey(keyhand)
End Sub

NOW IN YOUR FORM_LOAD EVENT() PLACE THIS CODE

Dim strname as String

strname = App.EXEName & ".Exe"
            Call IncludeAtStartup(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
            strname, App.Path & "\" & App.EXEName & ".exe")

hope this helps.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

place a shortcut of your vb application in windows startup folder. it will automatically launch your program whenever you will login to windows.

and for shutdown, there is no coding required. windows already has a logging off utility that logs off each user from the current session before your computer is going to be restarted or shut down and unloads/closes all running processes/programs from memory.

so make sure your program is running. you can ensure that by visiting the process list in windows task manager. now when a user logs off from his/her session windows will automatically unload your program and close it.

choudhuryshouvi 33 Posting Pro

why don't you guys see the replies that already given and post the same question again n again?

plz solve the existing thread, look there whether you got a proper response or not, if not then start a new thread. but before doing so atleast visit the thread once.

if i'm not wrong you have already posted a thread couple of days ago having the same matter like this. look there, some replies have been made.

go to your existing thread which is
Simple Login (Through text file)
and look for a reply which i made at no. 3

regards
Shouvik

choudhuryshouvi 33 Posting Pro

the common dialog control is an intrinsic control. it cannot be displayed in your toolbox by default. you have to manually add it.

please goto Project->Components

then select Microsoft Common Dialog Control 6.0

click Apply->Ok
Now you can see it on your toolbox

regards
Shouvik

choudhuryshouvi 33 Posting Pro

and one more thing my frnd, if you got your answer then please mark this thread as solved. this will help other perople to easily find solved threads which signifies a definite solution to their problem having same doubts like you.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

you r welcome.
just ask us whenever you stucked..

bye.

choudhuryshouvi 33 Posting Pro

i wanna to get size of file.
help me how to get this. anyone know how to do this.
any help will be appreciated :)

this is a simple but efficient code..

Dim fln,result
Dim fname as String

fname="c:\windows\regedit.exe"

fln = FileLen(trim(fname))
result = CInt((fln / 1024) / 1024) & " MB" & "(" & fln & " BYTES)"

Msgbox "FileSize is -->" & result

you will display a message box containing this text :-

FileSize is --> 9 MB(9016447 BYTES)

hope this helps you.

regards
Shouvik

dnk commented: much efficient :) +1
choudhuryshouvi 33 Posting Pro

see the answers in inline...

Function return type by default is integer in C. & if we do the same prog in C,it returns 3 not 3.333333....But in VB the function return type is Variant????Right or Wrong?

yes its right

variant is data type which can hold the data of any type like integer,string,double...Right or wrong?

yes its right again

I want that the fn. return can integer value only by default, if we write
Private Function div(a, b) as double

only then it returns decimal value??

Plz reply frnds.:(

Just a little modification in your code and you will get exactly what you want..

Private Function div(byval a as integer,byval b as integer)as integer
div = a / b
End Function

or you can try this also...

Private Function div(byval a as integer,byval b as integer)
div = a / b
div=Cint(div)
End Function

hope this helps..

regards
Shouvik

choudhuryshouvi 33 Posting Pro

did you read my previous reply?

i think you didn't. that's why you are asking the same question again n again...

combining menu items from diff. parent menu cannot be possible. to show these menu4 and menu5 together in runtime you must create them under the same menu head.

hope you will notice now...

regards
Shouvik

choudhuryshouvi 33 Posting Pro

Hi...
i want to make flash window...
after program completed something task then that window will flash.
i ask my friend and he said to use api function. but i don't have an idea to do this.
please help me masters...

any help will be appreciated.

best regard
Jade

here is a sample snippet for you. try it. just place a command button and a timer on your form for testing. set an interval for the timer. for ideal experience set it to 1000.

give me a feedback after you try this code.

Option Explicit

Private Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, _
ByVal bInvert As Long) As Long

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
FlashWindow Me.hWnd, True
End Sub

hope this will help you.

regards
Shouvik

Jade_me commented: Great Code :) +1
choudhuryshouvi 33 Posting Pro

the menu items that you create for your form can be visible in run mode only. when you right click on your form in the designer you will show vb6's system submenus.

as far as i know combination of menu items is not possible. in order to show the items fillcolor and small you must add them under the same menu. but might be some way using some APIs. try searching in google or into the following site :-
http://msdn.microsoft.com

regards
Shouvik

choudhuryshouvi 33 Posting Pro

Hi sonia, what about my reply?
did you read it?

there i answered all those which you have noticed and told in my previous reply.

here no one is trying to find your faults. we are all here to give you proper suggestions, tricks,tips and thats all. which reply will be good for you and which is not it completely depends upto you. there is no question about egoism.

just ask your questions,problems whatever you have and we all here will try to help you by the best.

so finally give me a feedback here whether have you got answer to all of your questions which you replied for Me and Jx_Man.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

what have you meant by printer properties?

plz explain in detail.

or you can try this :-

add the component Microsoft Common Dialog Control 6.0 from Project->Components.
make an instance of it on your form.
now take a comman button and place this code,

Private Sub Command1_Click()
[B]CommonDialog1.ShowPrinter[/B]
End Sub

It will show you the windows Print dialog box (the same one which you might be seen when trying to print documents from external windows applications like Notepad,wordpad,etc.

using API becomes more advance technique. you can API to access printer properties and configure it right through your code like finding its driver, setting up proper port, sending print commands,etc.,etc. For API reference Visit This Link.

regards
Shouvik

Sawamura commented: great help :) +1
Naruse commented: simple and nice +1
choudhuryshouvi 33 Posting Pro

Ok....here is the code that I used....

[B]''opening my database[/B]
use BILLING_SYSTEM
[B]''fetching all tables[/B]
select distinct name from sysobjects where xtype='U'

regards
Shouvik

choudhuryshouvi 33 Posting Pro

Its been a pleasure to share my code here.
This is the code which I used in my application. Hope others will be benefited from this having same problem like me.

[B]''this is for creating the user "BS" and associate it with the "BILLING_SYSTEM database[/B]
EXEC SP_ADDLOGIN 'BS','BS','BILLING_SYSTEM'
USE BILLING_SYSTEM
[B]''these are for granting server roles[/B]
EXEC SP_ADDSRVROLEMEMBER 'BS', 'sysadmin'
EXEC SP_ADDSRVROLEMEMBER 'BS', 'securityadmin'
EXEC SP_ADDSRVROLEMEMBER 'BS', 'serveradmin'
EXEC SP_ADDSRVROLEMEMBER 'BS', 'setupadmin'
EXEC SP_ADDSRVROLEMEMBER 'BS', 'processadmin'
EXEC SP_ADDSRVROLEMEMBER 'BS', 'diskadmin'
EXEC SP_ADDSRVROLEMEMBER 'BS', 'dbcreator'
[B]''these are for granting various database manipulation permissions[/B]
EXEC SP_ADDUSER 'BS','BS','public'
EXEC SP_ADDROLEMEMBER 'db_owner','BS'
EXEC SP_ADDROLEMEMBER 'db_accessadmin','BS'
EXEC SP_ADDROLEMEMBER 'db_securityadmin','BS'
EXEC SP_ADDROLEMEMBER 'db_ddladmin','BS'
EXEC SP_ADDROLEMEMBER 'db_backupoperator','BS'
EXEC SP_ADDROLEMEMBER 'db_datareader','BS'
EXEC SP_ADDROLEMEMBER 'db_datawriter','BS'
EXEC SP_ADDROLEMEMBER 'db_denydatareader','BS'
EXEC SP_ADDROLEMEMBER 'db_denydatawriter','BS'

Hope the above syntax will be acceptable and one more thing i must say this code is working like snapping knife in butter.

regards
Shouvik

peter_budo commented: Nice job, keep up good work +7
choudhuryshouvi 33 Posting Pro

Thank you very much for saying this -

always try to appreciated others comment.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

explain more clearly.
if possible supply screenshots.

choudhuryshouvi 33 Posting Pro

Hey Jx_Man, hey these are small errors even a fresher like me will be able to find it out. No Sorry.
Hey Choudhary See the prog below--
Private Sub Command2_Click()
i = 20
j = 10
Print i - j
End Sub

Private Sub Command3_Click()
Dim i As Integer
Dim j As Integer
i = 10
j = 20
Print i + j
End Sub

No error is coming in the above prog,as u said if u declare the variables inside the procedure they are local to the procedure.

And also no error is coming in ur prog(Last two lines).

Second thing, By Default Option Explicit is off in Vb, & on in VB.Net.
Therefore even if i n not declaring the variables,noo error is coming see below
Private Sub Command3_Click()
i = 10
j = 20
Print i + j
End Sub

Plz check variables defined inside the procedure are local to the procedure or not & REply.


FUNCTIONs--

I want to ask there is no return statement in VB, then how we do the foll. prog-

Private Sub Command1_Click()
Dim sum As Integer
sum = Add(10, 20)
Print sum
End Sub

Private Function sum(a As Integer, b As Integer)
Dim c As Integer
c = a + b
return c
End Function

Ok...
your program is running without …

choudhuryshouvi 33 Posting Pro

you can also use a variable without declaring the same. but for this you must turn off "Required Variable Declaration" option.

it is always recommended that you use variables after explicitly declaring them. this will help boosting up your program process by preventing memory wastage.

one more thing, you can declare a variable in anywhere inside your code. depending on the declaration section the variable's scope will be determined. if you use it in outside procedure or in general declaration it will treated as a shared or global variable and can be accessed from any procedure present in the same module. now if you declare a variable inside any procedure its scope will be limited to that procedure only where you have declared it. In order to initialize a variable you must follow the way Jx_Man said. and one more thing, the syntax you have used here is applicable in VB.Net not in VB6.

now for example,
declare a variable in form's general declaration section

Dim i as Integer

now the above var. can be accessed from any procedure like,

Private Sub Command1_Click()
i=10
Msgbox i
End Sub

Private Sub Command2_Click()
i=i+val(trim(Text1.text))
Msgbox i
End Sub

now declare another var. c inside a procedure like,

Private Function Sum(a as Integer,b as Integer)
Dim c as Integer

c=a+b
Sum=c
End Sub

now call this from an event like,

Private …

choudhuryshouvi 33 Posting Pro

you can use the debug window to check whether an expression or any operation for which you have written code is working or not.

whether you are getting correct result which supposed to be or not. make sure you have created some breakpoints in your code before trying this.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

can any one help me in the following problem

i have created a exe file in visual basic. in my application if i click a command box a excel file will open. the excel file is accessible in my system. but if the exe file is executed in any other pc the user is unable to access the excel.

pls help.........

the error you are facing is because you haven't copied the excel file from your pc to the destination pc and of course you might have specified the physical path of the file in your code which may or may not be exist in your target pc. the solution for your problem is, make sure you have copied both the exe and excel files to your target pc and try to avoid fixing paths in your code. instead of it always use the same path as your project directory and store all of your dependent files inside the folder from where you are running the exe file.

though you have not specified here in which way you have made your program files available in the target pc (whether just simple copied the files from ur pc and paste them inside a folder in the target pc or you have built a setup package for your project to install all files in the target pc), it is always recommended that you must create an installer for your project before running your application in some other computer where vb6 is …

choudhuryshouvi 33 Posting Pro

can you afford to explain it more clearly?

choudhuryshouvi 33 Posting Pro

one thing you can do here.

save the event logs from your hyperterminal client. use file->save as option. it will create a session file. probably like a text file. then use file manipulation functions in vb to read data from this session file and send it right to the database.

well this is just a tricky suggestion from me.
the decision depends upto you.

choudhuryshouvi 33 Posting Pro

How to design using crystal report with a particular record
and the coding in vb

that's a very big issue. try searching for some crystal report tutorials in google.

now if you got some problems when you design the report or firing it up from vb6 , then post it right here. someone should obviously reply you.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

HI, I am having a few problems, I want to make a simple login that will read a text file where the "username","password" will be, it will be displayed like this:

"username1","password1"
"username2","password2"

etc, I would like it so that the login form will read the data, if a user enters wrong username or wrong pass then they will get a message.
username1 would have to match with password1,

Anyway I need the right code to help me do this, as I have create a simple registration process that writes the username/password as above into a text file:

try the following code.
i think this code becomes the definite solution to your problem.
just place two textboxes and a button (with default object names) on your form for testing.
plz give me a feedback if this helps you.

place this code under Command1_Click() event and of course create a text file "user.txt" in your project folder with some sample values for testing with this code. the format should be in the following format :-

"username1","password1"
"username2","password2"
.
.
and so on...

Dim uname As String, pwd As String
Dim is_matched As Boolean

If Trim(txtusername.Text) = "" Or Trim(txtpassword.Text) = "" Then
    MsgBox "Missing login info."
    txtusername.SetFocus
    Exit Sub
End If

is_matched = False

Open App.Path & "\user.txt" For Input As #1
    Do While Not EOF(1)
        Input #1, uname, pwd
        If Trim(uname) = Trim(txtusername.Text) And _
            Trim(pwd) = Trim(txtpassword.Text) …
choudhuryshouvi 33 Posting Pro

the problem is when i add data into the database it throws me this error at times
Run-time error `-2147217887(80040e21)`
multiple-step operation generated errors.check each status value

do you know the meaning of this error message ?

you will face this error when you try to store value in a field and size of your data is more than the specific field's size.
for example, you are trying to store time in a age field which is probably a numeric field. now if didn't the change default value it should be 10. now if you are inserting time it can be in a format like HH:MM:SSSS which becomes a numeric value also. now each data type has a limit to store values. a numeric field can hold values from -32768 to +32767. now if you try to store any value beyond this range you will face the above error. the same thing is applicable on other data types also.

so check the field size and its data type and then store your value.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

first of all there is no crystal report control available with crystal report 11 library. you have to use the new one crystal report viewer to fire up your reports from your vb6 application.

to use the crystal report viewer in your project, you need to make a full installation of crystal report 11.0 software. only copying the activex component to your system directory will not do the job.

after installing the software goto project->componets and there you will found crystal report viewer control. add this to your project.

now for the coding purpose, you should know the syntax for firing a report in crystal report 11 is completely diff. than its earlier versions. as it is built to support .net framework it doesn't support previous methods/properties of the previous crstl32.ocx any more. to get some sample coding make searching in google. you will easily find some.

regards
Shouvik