Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

vb 2010 express help


  • Please log in to reply
11 replies to this topic

#1 snglnluvnit

snglnluvnit

  • Members
  • 184 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Wisconsin
  • Local time:12:52 AM

Posted 03 April 2012 - 12:03 PM

Hello all, new to programming so please feel free to assume I don't know much!!! Here is my question: I am writing a program in VB 2010 Express, for a friend who runs an Auto shop. I want to assist him in his invoicing, and financial tracking. As of now I would like to either have a text document that has a starting Invoice # and then increment it each time he prints an invoice, and then save it, so it can be accessed again and incremented again. My other thought is to (not even sure this is possible), but to create a dynamic variable withing the program itself to store the beginning invoice number, then "delete" it as a new number/variable would be created for the next invoice then save the newly created variable containing the new invoice number.
Any suggestions/guidance is MUCH APPRECIATED!!!

Thanks,
Scott

BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:11:52 PM

Posted 03 April 2012 - 12:10 PM

If you want to assist him in financial tracking, then I would strongly recommend pointing him at one of the many awesome and full featured accounting packages available, such as Quickin or QuickBooks. It's going to take you far less time to learn and explain to him one of these pieces of software than it is going to be to write equivalent functionality yourself. Plus, if you go with a vendor like this, you're getting a well known and well tested piece of software.

No offense to your coding ability, but if you're new at writing programs, I'd not be trusting my money or my customer database to your code. It has nothing to do with you and everything to do with lack of a track record; think of it as something like a "credit history" -- you may be a responsible debtor but credit card companies don't trust you until you show them....

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 snglnluvnit

snglnluvnit
  • Topic Starter

  • Members
  • 184 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Wisconsin
  • Local time:12:52 AM

Posted 03 April 2012 - 12:42 PM

No offense taken!! LOL!! One of the factors regarding this decision is that it would take him longer, and be extremely more confusing/frustrating for him to learn a program as "complete"/ complex as Quicken (he struggles with computers/software). This program simply allows him to tab through and enter data that needs to be calculated & stored in text files, so at the end of each month they have their data in a form that THEY can use. I'm not printing/displaying any reports at the end just simple text docs with all their totals, daily, weekly, monthly, yearly. I have the program written all ready, (except the storage into documents part) and the Invoice number part, and just need help with this particular piece.

Thanks,
Scott

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:52 AM

Posted 03 April 2012 - 02:36 PM

The easiest way to do this would be to keep a separate directory to store the files. Then when getting ready to save a file, count the number of files in the directory, and add 1 to the number of the save file. No need to store a variable at all.

From a practical standpoint though, using a date might be a bit more helpful in the instance one wants to retrieve a particular invoice.

#5 snglnluvnit

snglnluvnit
  • Topic Starter

  • Members
  • 184 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Wisconsin
  • Local time:12:52 AM

Posted 03 April 2012 - 06:14 PM

I had considered just using the system date/time as an invoice number..hmmm..might be the quick way out ..Thanks

#6 raw

raw

    Bleeping Hacker


  • Members
  • 2,577 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Texas
  • Local time:01:52 AM

Posted 09 April 2012 - 12:37 AM

The easiest for me was to use Open Office with an Invoice template.

rawsig.png

 rawcreations.net          @raw_creations


Current systems: WHAT OS, BackTrack-raw, PCLinuxOS, Peppermint OS 6, Kali Linux

and a custom Linux From Scratch server hosting a bunch of top secret stuff.


#7 snglnluvnit

snglnluvnit
  • Topic Starter

  • Members
  • 184 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Wisconsin
  • Local time:12:52 AM

Posted 09 April 2012 - 05:32 AM

I plan on getting back at it tonight or tomorrow; I had considered OO or Libre, and then just filling in numbered/named text boxes..I will post back what I got to work. Thanks Scott

#8 ident

ident

  • Members
  • 109 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Cambridge
  • Local time:02:52 AM

Posted 11 April 2012 - 05:15 AM

If you wish to save a simple object in this case an Integer you should be taking a look at the My.Settings Object and Using My.Settings. I would like to point out that the settings file is generated per profile and also known to be unstable. I have more then once encounter iffy settings.

The next solution would be to use XML. I prefer XML especially more so with the introduction of LINQ. Now being a new programmer single line queries will likely confuse you. We can look at this a little bit further down the road. We can also take a look at textfile settings. One i would not choose but are very simple. All this is based on your second post though.

As for regarding the invoice count i also agree with groovicus. We can use the DirectoryInfo Class to create an array of files. Then using the StreamWriter Class we write the file. In programming we always start from 0 as groovicus pointed out. How ever you will not need to add one using the Directory Info Class.

A quick example implementing what i have just spoke about.

Option Strict On

Public Class MainForm

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim FileList() As IO.FileInfo = New IO.DirectoryInfo("C:\Invoices").GetFiles

        Using writer As IO.StreamWriter = New IO.StreamWriter("C:\Invoices\Logs\InvoiceCount.txt")
            writer.WriteLine(String.Format("This week's Invoice count is {0}", FileList.Count))
        End Using

    End Sub
End Class

A few other things you will need to handle is validation. Check the File & Folder exists. If not recreate them. Exception handling. What if the file is locked? For this we can use the Try...Catch...Finally Statement (Visual Basic).

Finally you will need to decide if you wish to over write the file each time or append. This example over writes.

Edited by ident, 11 April 2012 - 05:31 AM.


#9 snglnluvnit

snglnluvnit
  • Topic Starter

  • Members
  • 184 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Wisconsin
  • Local time:12:52 AM

Posted 12 April 2012 - 12:32 AM

Sorry for not responding sooner I have not had a chance to work on program this past week. ident... you've gone way beyond my knowledge base...lol. I am hoping to avoid handling any "errors", but will cross that bridge when/if I come to it, but thanks. I think I am going to just open/read/close/delete a text document that has the last invoice number used, then create another to save the new last invoice number with same name. Does that sound do-able?? Also I would like to open a MS/OO word template and write some info to it in text boxes.. can you direct me in that area??

Thanks,
Scott

#10 ident

ident

  • Members
  • 109 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Cambridge
  • Local time:02:52 AM

Posted 12 April 2012 - 06:26 AM

Unfortunately errors happen. Thats why we validate as much as possible then wrap a Try block around parts of are code that we can not validate. Exceptions do and will happen.

If you open and read the value of this text document. How will you know if it is accurate. I really would suggest not going down that route.

I do have a few MS word classes here i wrote that open word and infill text fields. This will need you to set bookmarks in your word template. How ever i wrote these some years ago and there are likely more efficient ways to go about manipulating word. I will check on this later today before i post.

#11 snglnluvnit

snglnluvnit
  • Topic Starter

  • Members
  • 184 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Wisconsin
  • Local time:12:52 AM

Posted 12 April 2012 - 08:16 AM

I certainly understand about the "errors happen"!! I don't understand how/why the value from the text document would not be accurate. Don't misunderstand me, I'm not inferring that it is not possible, I just can not think of a situation that would cause that to be the case. Maybe I should just use the system date/time for invoice number.

#12 ident

ident

  • Members
  • 109 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Cambridge
  • Local time:02:52 AM

Posted 12 April 2012 - 09:56 AM

Why take the chance? What if Two new invoices are added. Or a invoice is canceled and removed. This would require manual work. All this can be avoided by getting the file count.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users