Assistance with coding
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Assistance with coding

  1. #1
    Join Date
    Nov 2013
    Location
    PA
    Posts
    3

    Assistance with coding

    I'm attempting to create a vb type program via excel for my company. i took some classes but couldn't finish years due to work and $. i know my coding is incorrect but i cant seem to find the appropriote guides.

    i'm trying to basicly create a calculator for parts of our inventory. some things were coming back to me as i was making my attempts but still cant seem to get it.

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,843

    Re: Assistance with coding

    Well you will need to ask a more direct question before anyone will be able to give you an answer.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Nov 2013
    Location
    PA
    Posts
    3

    Re: Assistance with coding

    my apologies basiclly i am counting wings. 8 piece, 14 piece and loose bags.


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim smblorder As Single, bgblorder As Single, smtotal As Single, bgtotal As Single, bags As Single, Total As Single

    smblorder = Cells(3, 4)
    bgblorder = Cells(4, 4)
    smtotal = Cells(3, 5)
    bgtotal = Cells(4, 5)
    smtotal = smblorder * 0.1111
    bgtotal = bgblorder * 0.17
    Cells(5, 5) = bags

    End Sub

    Option Explicit
    Option Base 1
    Private Sub codeAdd_Click()
    Dim smtotal As Single, bgtotal As Single, bags As Single
    Total = smtotal + bgtotal + bags
    Cells(6, 5) = Total

    End Sub

    Option Explicit
    Option Base 1


    smtotal = smblorder * 0.1111
    bgtotal = bgblorder * 0.17

    End Sub

  4. #4
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,843

    Re: Assistance with coding

    I still don't see a question there

    No idea what your variables are but I can tell you that in the Sub codeAdd your total will be 0 but it is also not dimmed so would result in an error first
    None of the vars you are adding together have a value so in effect what you are doing is

    Total=0+0+0

    Cells(6,5)=0
    The last part of code is missing the Sub definition

    It also looks like this code is from more than one module

    So again, you really need to ask a more direct question rather than having us try and guess what you need help with
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Nov 2013
    Location
    PA
    Posts
    3

    Re: Assistance with coding

    again my aplolgies. Name:  wings.jpg
Views: 38
Size:  26.3 KB

    the first box beside 8 piece is how many orders are preped. i need to multply that by .1111 to make the box beside that say how much of a bag is prepped. same with the 14 piece. the box beside bags is how many loose bags i have and the total is the two totals (8 & 14 piece decimals) plus the bags. the grey areas i need to lock so they cant be manually changed. i cant remember the correct coding to make this work. I guess what i'm asking is what changes to i need to my coding for this to work correctly?

  6. #6
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,843

    Re: Assistance with coding

    Well you need to make references to these entries in your code in order to work with the values

    I have never created a form in Excel so I am not sure what the syntax is for text boxes there in Vb the default name of a textbox is Text1 and you access its value using Text1.text It may be the same in Excel or it may be a bit different.

    Your picture does not seem to jive with your description though
    3*.1111 would not equal .2222 it would be .3333
    2*.1111 would be .2222 not .34

    0.2222+0.34+1 would not be .7322 it would be 1.5622

    .3333+.2222+1 would be 1.5555

    so I have no idea where those numbers come from

    If it were VB then I would have 3 textboxes for examples sake I will use the default names of Text1 text2 and text3
    I would use 3 labels for the output call them label1 label2 and label3 of course there would also be labels for the other text on the form
    Code:
    Label1.Caption=Text1.Text *.1111
    Label2.Caption=Text2.Text *.1111
    label3.caption=label1.caption+label2.caption+text3.text
    now of course these really should be tested to make sure the entry is valid before processing and should be converted to a numeric var and the vars are what you should actually add but maybe that will get you pointed in the right direction
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center