locked
Vendo Printing Machine RRS feed

  • Question

  • Our system is entitled vendo printing machine. It's functions are:

    1) You can browse different files like documents, powerpoint presentation and excel worksheets. Just click the browse button then the file path will show on the textbox.

      OpenFileDialog1.ShowDialog()
            txtfile.Text = OpenFileDialog1.FileName

    2)After that you can edit your document by clicking the edit button that will open the microsoft word application or software and then print... but because our system is a coin operated machine you should insert first the exact amount of coin that is being asked before you can print your document for example 3pesos per page... Is there anyone of you who have any idea on how to code this???

    Dim FileName As String
            FileName = OpenFileDialog1.FileName & ""
            Dim objWord As New Word.Application
            objWord.Visible = True
            objWord.Documents.Open(txtfile.Text, , , True)

    My code ended in here... it can only open and edit my document

    3) There is also a function that an admin user can change the price per page and the number of the remaining bond paper on printer, with a database that will show the profit or payroll-like database?Can you also help me with these?Thank You


    Tuesday, November 27, 2018 3:43 PM

Answers

  • Here is a incomplete path to follow, what is there works (expect for the print method which is a suggestion).

    Public Enum DocumentType
        PowerPoint
        Excel
        Word
    End Enum
    Public Class Operations
        ''' <summary>
        ''' Price to print by page for each document type in DocumentType
        ''' </summary>
        Protected Dic As Dictionary(Of DocumentType, Decimal) = New Dictionary(Of DocumentType, Decimal) From
            {
                {DocumentType.PowerPoint, CDec(3.5)},
                {DocumentType.Excel, CDec(2.5)},
                {DocumentType.Word, CDec(4.5)}
            }
        Public Property DisplayItems() As List(Of DocumentItem)
        Public Sub New()
            DisplayItems = New List(Of DocumentItem)()
            For Each kvp As KeyValuePair(Of DocumentType, Decimal) In Dic
                DisplayItems.Add(New DocumentItem() With {.Name = kvp.Key.ToString(), .Cost = kvp.Value})
            Next
        End Sub
        Public Function Charge(pDocumentType As DocumentType, pPages As Integer) As Decimal
            Dim result As Decimal = 0
            Select Case pDocumentType
                Case DocumentType.PowerPoint
                    result = CDec(Dic(DocumentType.PowerPoint) * pPages)
                Case DocumentType.Excel
                    result = CDec(Dic(DocumentType.Excel) * pPages)
                Case DocumentType.Word
                    result = CDec(Dic(DocumentType.Word) * pPages)
            End Select
            Return result
        End Function
        ''' <summary>
        ''' Place to do the printing
        ''' </summary>
        ''' <returns></returns>
        Public Function Print() As Boolean
            Throw New NotImplementedException
        End Function
    End Class
    

    .

    Public Class DocumentItem
        Public Property Name() As String
        Public Property Cost() As Decimal
    
        Public Overrides Function ToString() As String
            Return Name
        End Function
    End Class

    .

    Public Class Form1
        Private _operations As New Operations
        Private Sub cmdGo_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim documentType = DirectCast([Enum].Parse(GetType(DocumentType),
                cboDocumentTypes.Text), DocumentType)
            '
            ' Let's say there are three pages
            '
            _operations.Charge(documentType, 3)
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            cboDocumentTypes.Items.AddRange([Enum].GetNames(GetType(DocumentType)))
            cboDocumentTypes.DataSource = _operations.DisplayItems
        End Sub
    End Class
    


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by estudyante Wednesday, November 28, 2018 4:24 PM
    Tuesday, November 27, 2018 5:52 PM

All replies

  • I'm just asking for help, if you don't want to help then don't
    Tuesday, November 27, 2018 4:29 PM
  •     What did he say?

          

      Must be a rough morning.  8)


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, November 27, 2018 4:36 PM
    Tuesday, November 27, 2018 4:36 PM
  • Here is a incomplete path to follow, what is there works (expect for the print method which is a suggestion).

    Public Enum DocumentType
        PowerPoint
        Excel
        Word
    End Enum
    Public Class Operations
        ''' <summary>
        ''' Price to print by page for each document type in DocumentType
        ''' </summary>
        Protected Dic As Dictionary(Of DocumentType, Decimal) = New Dictionary(Of DocumentType, Decimal) From
            {
                {DocumentType.PowerPoint, CDec(3.5)},
                {DocumentType.Excel, CDec(2.5)},
                {DocumentType.Word, CDec(4.5)}
            }
        Public Property DisplayItems() As List(Of DocumentItem)
        Public Sub New()
            DisplayItems = New List(Of DocumentItem)()
            For Each kvp As KeyValuePair(Of DocumentType, Decimal) In Dic
                DisplayItems.Add(New DocumentItem() With {.Name = kvp.Key.ToString(), .Cost = kvp.Value})
            Next
        End Sub
        Public Function Charge(pDocumentType As DocumentType, pPages As Integer) As Decimal
            Dim result As Decimal = 0
            Select Case pDocumentType
                Case DocumentType.PowerPoint
                    result = CDec(Dic(DocumentType.PowerPoint) * pPages)
                Case DocumentType.Excel
                    result = CDec(Dic(DocumentType.Excel) * pPages)
                Case DocumentType.Word
                    result = CDec(Dic(DocumentType.Word) * pPages)
            End Select
            Return result
        End Function
        ''' <summary>
        ''' Place to do the printing
        ''' </summary>
        ''' <returns></returns>
        Public Function Print() As Boolean
            Throw New NotImplementedException
        End Function
    End Class
    

    .

    Public Class DocumentItem
        Public Property Name() As String
        Public Property Cost() As Decimal
    
        Public Overrides Function ToString() As String
            Return Name
        End Function
    End Class

    .

    Public Class Form1
        Private _operations As New Operations
        Private Sub cmdGo_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim documentType = DirectCast([Enum].Parse(GetType(DocumentType),
                cboDocumentTypes.Text), DocumentType)
            '
            ' Let's say there are three pages
            '
            _operations.Charge(documentType, 3)
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            cboDocumentTypes.Items.AddRange([Enum].GetNames(GetType(DocumentType)))
            cboDocumentTypes.DataSource = _operations.DisplayItems
        End Sub
    End Class
    


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by estudyante Wednesday, November 28, 2018 4:24 PM
    Tuesday, November 27, 2018 5:52 PM