Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Visual Basic Programming

Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-2008, 09:27 PM
yonghan yonghan is offline
Newbie
 
Join Date: May 2008
Posts: 19
Rep Power: 3
yonghan is on a distinguished road
Default create log file

I want to ask for help for creating an activity logfie for example if the client delete data from the database,it will written to the logfile at what time he/she delete the data etc.Also i want to ask,is it possible to read ip and write it to log file from the client if the application was only installed on the server side,but the application was used by 3 clients?Thanks a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-20-2008, 03:24 PM
scsefrmr scsefrmr is offline
Learning Programmer
 
Join Date: May 2008
Posts: 39
Rep Power: 2
scsefrmr is on a distinguished road
Send a message via MSN to scsefrmr
Default Re: create log file

Hi yonghan,

For creating a log, you could open a file for output and print the information to it as it passes various parts of the application.

Code:
'-- Open a file for output --|
Open "c:\access.log" for output as #1
.................
.................
.................
'-- Set a variable to hold the text going into the log file --|
strTemp = << stuff to go into the log file >>
'-- Send variable into the log file --|
Print #1, strTemp
.................
.................
'-- And at the end, close the file --|
Close #1

If the client is accessing the server via Winsock (if the application is a Windows based app rather than a web application on a website), then you could get the users IP via the Winsock object on the server form... a la Winsock1.RemoteHostIP (if I remember right?)
And you can write that to the log file in the same way as above
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-20-2008, 03:52 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,882
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: create log file

How are you storing the data? And which version of VB are you using? .NET?
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-20-2008, 06:26 PM
scsefrmr scsefrmr is offline
Learning Programmer
 
Join Date: May 2008
Posts: 39
Rep Power: 2
scsefrmr is on a distinguished road
Send a message via MSN to scsefrmr
Default Re: create log file

Ah yes, didn't think to ask what version of VB he used...
For the record... my example code was in VB6.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-20-2008, 10:12 PM
yonghan yonghan is offline
Newbie
 
Join Date: May 2008
Posts: 19
Rep Power: 3
yonghan is on a distinguished road
Default Re: create log file

i'm using vb 6.I'm intending to make a log for the clients activity for example delete data etc.So the owner know what had happen..Are there any reference about winsock using vb 6??Thanks..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 05-20-2008, 10:19 PM
yonghan yonghan is offline
Newbie
 
Join Date: May 2008
Posts: 19
Rep Power: 3
yonghan is on a distinguished road
Default Re: create log file

The application was putted on the server,the clients are using it..Some sort of creating a shortcut to the application i suppose..Is it possible to get the clients ip that access the application??thanks..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-21-2008, 08:55 AM
scsefrmr scsefrmr is offline
Learning Programmer
 
Join Date: May 2008
Posts: 39
Rep Power: 2
scsefrmr is on a distinguished road
Send a message via MSN to scsefrmr
Default Re: create log file

For creating a log, the code I provided will work fine - I use it myself for the same purpose in another application I've made in the past.


Quote:
Originally Posted by yonghan View Post
The application was putted on the server,the clients are using it..Some sort of creating a shortcut to the application i suppose..Is it possible to get the clients ip that access the application??thanks..
Right... I originally thought there were 2 applications (a server side and a client side) which may have used winsock to communicate between them.

From the quote I've included, it seems as though there is only one application which is kept on the server which I wouldn't know how to get the client's IP address from
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-21-2008, 10:48 PM
yonghan yonghan is offline
Newbie
 
Join Date: May 2008
Posts: 19
Rep Power: 3
yonghan is on a distinguished road
Default Re: create log file

Ok,thanks..I also want to ask for help again..I wrote a function to add data to access.I'm intending to store the sold goods into it,and check when a transaction was made,are there the same date,code,name of the goods.If there are same,then the quantity field will be updated..I create it to see the most sold goods..Here are the codes..Please help me to check it..Or are there another way to get the most sold goods??Thanks..

Private Sub terlaku()
Dim a, Jumlah As Integer
Dim kode As String

For a = txtKode.LBound To txtKode.UBound
If txtKode(a).Text <> "" Then
If txtQty(a).Text <> "" Then
kode = txtKode(a).Text
rsterlaku.AddNew
rsterlaku!ID = CStr(Date) & " - " & strUser
rsterlaku!tgl = Date
rsterlaku!kd_brg = txtKode(a).Text
rsterlaku!nm_brg = txtNama(a).Text
rsterlaku!Qty = txtQty(a).Text
rsterlaku!User = strUser
rsterlaku!Update = Now
If rsterlaku.RecordCount > 0 Then
rsterlaku.MoveFirst
rsterlaku.Index = "tgl"
rsterlaku.Seek "=", Date
If Not rsterlaku.NoMatch Then
rsterlaku.Index = "kd_brg"
rsterlaku.Seek "=", kode
If Not rsterlaku.NoMatch Then
rsterlaku.Index = "user"
rsterlaku.Seek "=", lbluser.Caption
If Not rsterlaku.NoMatch Then
Jumlah = CInt(rsterlaku!Qty)
rsterlaku.Edit
rsterlaku!Qty = CStr(Jumlah + CInt(rsterlaku!Qty))
rsterlaku!User = strUser
rsterlaku!Update = Now
Else
If rsterlaku.NoMatch Then
rsterlaku.AddNew
rsterlaku!ID = CStr(Date) & " - " & strUser
rsterlaku!tgl = Date
rsterlaku!kd_brg = txtKode(a).Text
rsterlaku!nm_brg = txtNama(a).Text
rsterlaku!Qty = txtQty(a).Text
rsterlaku!User = strUser
rsterlaku!Update = Now
End If
End If
End If
End If
End If
End If
End If
rsterlaku.Update
Next a
End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 05-22-2008, 11:49 AM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,882
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: create log file

Don't forget to wrap [CODE ] and [/CODE ] tags around your code!

I'm not sure if your code is the most efficient way to write it. There are lots of End Ifs at the end, don't you think? Could you indent the code to make it easier to read?
__________________


Mr. Xav | Website | Forums | Blog

Last edited by Xav; 05-22-2008 at 11:52 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 05-22-2008, 10:11 PM
yonghan yonghan is offline
Newbie
 
Join Date: May 2008
Posts: 19
Rep Power: 3
yonghan is on a distinguished road
Default Re: create log file

Private Sub terlaku()
Dim a, Jumlah As Integer
Dim kode As String

For a = txtKode.LBound To txtKode.UBound

If txtKode(a).Text <> "" Then

If txtQty(a).Text <> "" Then

kode = txtKode(a).Text

rsterlaku.AddNew
rsterlaku!ID = CStr(Date) & " - " & strUser
rsterlaku!tgl = Date
rsterlaku!kd_brg = txtKode(a).Text
rsterlaku!nm_brg = txtNama(a).Text
rsterlaku!Qty = txtQty(a).Text
rsterlaku!User = strUser
rsterlaku!Update = Now

If rsterlaku.RecordCount > 0 Then
rsterlaku.MoveFirst
rsterlaku.Index = "tgl"
rsterlaku.Seek "=", Date

If Not rsterlaku.NoMatch Then
rsterlaku.Index = "kd_brg"
rsterlaku.Seek "=", kode

If Not rsterlaku.NoMatch Then
rsterlaku.Index = "user"
rsterlaku.Seek "=", lbluser.Caption

If Not rsterlaku.NoMatch Then

Jumlah = CInt(rsterlaku!Qty)
rsterlaku.Edit
rsterlaku!Qty = CStr(Jumlah + CInt(rsterlaku!Qty))
rsterlaku!User = strUser
rsterlaku!Update = Now

Else

If rsterlaku.NoMatch Then

rsterlaku.AddNew
rsterlaku!ID = CStr(Date) & " - " & strUser
rsterlaku!tgl = Date
rsterlaku!kd_brg = txtKode(a).Text
rsterlaku!nm_brg = txtNama(a).Text
rsterlaku!Qty = txtQty(a).Text
rsterlaku!User = strUser
rsterlaku!Update = Now

End If

End If

End If

End If

End If

End If

End If

rsterlaku.Update

Next a

End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 04:22 PM
Visual Studio 2008: C# Reading Files Jordan CSharp Tutorials 8 06-20-2008 11:54 AM
Windows Shortcut List - Saves Time 2stamlers The Lounge 6 04-10-2008 07:58 AM
How to create a text file on my host and save the input of my form there ? kresh7 Visual Basic Programming 2 11-27-2007 04:00 PM


All times are GMT -5. The time now is 05:24 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads