Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6937169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:19:42+00:00 2026-05-27T12:19:42+00:00

As it is right now I have a bit of code that kind of

  • 0

As it is right now I have a bit of code that kind of looks like this (a little paraphrased but Im sure you get the idea)

   If ComboBox1.SelectedIndex = 1 Then
        swEV2.Stop()
        If ComboBox3.SelectedIndex = 0 Then
            xlWorkSheet202.Activate()
            xlWorkSheet202.Cells((AT + 2), 3) = TextBox1.Text
            xlWorkSheet202.Cells((AT + 3), 2) = "PSS (kBs)"
            xlWorkSheet202.Cells((AT + 3), 3) = "USS (kBs)"
            xlWorkSheet202.Cells((AT + 3), 4) = "User %"
            xlWorkSheet202.Cells((AT + 3), 5) = "Kernel %"
            xlWorkSheet202.Cells((AT + 3), 6) = "Total %"
            xlWorkSheet202.Cells((AT + 4), 1) = "Min:"
            xlWorkSheet202.Cells((AT + 5), 1) = "Max:"
            xlWorkSheet202.Cells((AT + 6), 1) = "Average:"
            xlWorkSheet202.Cells((AT + 7), 1) = "Median:"
            xlWorkSheet202.Cells((AT + 8), 1) = "Stan Dev:"
        ElseIf ComboBox3.SelectedIndex = 2 Then
            xlWorkSheet204.Cells((WT + 2), 3) = TextBox1.Text
            xlWorkSheet204.Cells((WT + 3), 2) = "PSS (kBs)"
            xlWorkSheet204.Cells((WT + 3), 3) = "USS (kBs)"
            xlWorkSheet204.Cells((WT + 3), 4) = "User %"
            xlWorkSheet204.Cells((WT + 3), 5) = "Kernel %"
            xlWorkSheet204.Cells((WT + 3), 6) = "Total %"
            xlWorkSheet204.Cells((WT + 4), 1) = "Min:"
            xlWorkSheet204.Cells((WT + 5), 1) = "Max:"
            xlWorkSheet204.Cells((WT + 6), 1) = "Average:"
            xlWorkSheet204.Cells((WT + 7), 1) = "Median:"
            xlWorkSheet204.Cells((WT + 8), 1) = "Stan Dev:"

This goes on 3 more times in a few different places… So now I am trying to refactor the code to make it cleaner and shorter.

What I would like to do is this:

  If ComboBox1.SelectedIndex = 1 Then
        swEV2.Stop()
        If ComboBox3.SelectedIndex = 0 Then
            Excelupdate(xlWorkSheet203, AT)
        ElseIf ComboBox3.SelectedIndex = 2 Then
            Excelupdate(xlWorkSheet204, WT)

    Private sub ExcelUpdate(byref worksheet as object, byref update as string)

        worksheet.Activate()
        worksheet.Cells((update + 2), 3) = TextBox1.Text
        worksheet.Cells((update + 3), 2) = "PSS (kBs)"
        worksheet.Cells((update + 3), 3) = "USS (kBs)"
        worksheet.Cells((update + 3), 4) = "User %"
        worksheet.Cells((update + 3), 5) = "Kernel %"
        worksheet.Cells((update + 3), 6) = "Total %"
        worksheet.Cells((update + 4), 1) = "Min:"
        worksheet.Cells((update + 5), 1) = "Max:"
        worksheet.Cells((update + 6), 1) = "Average:"
        worksheet.Cells((update + 7), 1) = "Median:"
        worksheet.Cells((update + 8), 1) = "Stan Dev:"
     end sub

I thought for sure the above would work but it still seems that I am missing something, when I open the excel sheet nothing was printed. This would cut down the lines of code that I have in half easily, so I would love to find a solution for this

Thanks Guys

……………………………………………….

Edit (Sorry those comment boxes are terrible for writing anything)

……………………………………………….

alright I tried changing these lines of code:

        If ComboBox2.SelectedIndex = 1 Then
            If ComboBox3.SelectedIndex = 0 Then
                ExcelUpdate(xlWorkSheet202, AT, CDbl(Pvalue), CDbl(uvalue), CDbl(UserRx.Match(line).Value), CDbl(KernelRx.Match(line).Value))
            ElseIf ComboBox3.SelectedIndex = 1 Then
                ExcelUpdate(xlWorkSheet203, GT, CDbl(Pvalue), CDbl(uvalue), CDbl(UserRx.Match(line).Value), CDbl(KernelRx.Match(line).Value))
            ElseIf ComboBox3.SelectedIndex = 2 Then
                ExcelUpdate(xlWorkSheet204, WT, CDbl(Pvalue), CDbl(uvalue), CDbl(UserRx.Match(line).Value), CDbl(KernelRx.Match(line).Value))
            ElseIf ComboBox3.SelectedIndex = 3 Then
                ExcelUpdate(xlWorkSheet205, OT, CDbl(Pvalue), CDbl(uvalue), CDbl(UserRx.Match(line).Value), CDbl(KernelRx.Match(line).Value))
            End If
        End If

Private Sub ExcelUpdate(ByVal Sheet As Object, ByVal update As Integer, ByVal pval As Double, ByVal uval As Double, ByVal user As Double, ByVal kernel As Double)
    update = update + 1
    Sheet.cells(update, 1) = timenow
    Sheet.cells(update, 2) = pval
    Sheet.cells(update, 3) = uval
    Sheet.cells(update, 4) = user
    Sheet.cells(update, 5) = kernel
    Sheet.cells(update, 6) = cdbl(kernel + User)
 end sub

But the excel sheets still do not update with the new information. Is there anything else im missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:19:43+00:00Added an answer on May 27, 2026 at 12:19 pm

    I would check/change a couple of things:

    1) Change the ByRefs in the function to ByVal. You don’t need to update the reference to the worksheet or modify the string, so ByRef is not need.

    2) Determine the data type of the update parameter. You are mixing operation and types, which could result in an incorrect cells reference.

    If the goal of the cell reference is:

    worksheet.Cells(("A2"), 3)
    

    then you should change your code to:

    worksheet.Cells((update & "2"), 3)
    

    If the goal of the cell reference is:

    worksheet.Cells((12), 3)
    

    then you should change the update parameter type:

    update as integer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have something like this in NHibernate: Expression.Like(property, value, MatchMode.Anywhere) and that
Right now I have this SQL query which is valid but always times out:
Right now i have a line of code, in vb, that calls a text
I have this code that creates a little speech bubble. I am going to
I have some code (that is working), but I just want to make sure
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
Right now I have the following code working: @UiHandler(usernameTextBox) void onUsernameTextBoxKeyPress(KeyPressEvent event) { keyPress(event);
I'm not even sure how to begin wording this question, but basically, I have
So I have this bit of code: = f.input :aspectRatioId, :label => 'Aspect Ratio',
Right now we have all our code gathered in main.lua. We don't want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.