Excel Vba - Can The Lines Of Code Be Reduced In This .net Code

Jul 26, 2011

I have the following code, my employer wants me to reduce the lines of code to do the job.

Private Function getClientSheetNames(Optional ByVal type As String = "all") As List(Of String)
If type = "extra" Then
Return clientExtraSheetNames
End If

[code].....

I am not able to make out how can I cut the lines and have the same functionality !Are there any vb.net construct that can reduce the loc by better implementation ?Can I have a new function to be called from getClientSheetNames and getDevSheetNames that will can implement code resue ?Can I introduce polymorphism in a possible new function ?

View 1 Replies


ADVERTISEMENT

Save VB Code Ie. The Extension Which Will Open As Macro In Excel Not Code Created With VBA In Excel?

Nov 9, 2010

I can do this using VBA, but I want to be able to create the code using a compiled VB programme, which can then be opened in Excel.

View 1 Replies

Comment Multiple Lines Of Code/block Of Code In VB?

Jul 1, 2009

How to comment multiple lines of code/block of code in VB?

View 5 Replies

Another OPTIMIZING Macro Vba Code For Excel 2007 - The Code Is A Sort Of Transposer For Data

Sep 9, 2011

this code was not done by me originally and there are some thigns here i dont quite understand i have altered it a bit from my coworkers code to suit my data and it works. but too slow. and when i have 4000+kb excel files it might freeze altogether. ( I have checked tho that when and after this transposer runs it will still be within the excel row limit, i had done calculations before and made a macro to automatically split excel files based on number of columns and rows to make sure this is so ). This code seems to start out fast then goes slower the longer it runs. at least this is what it seems liek to me.

[Code]....

View 2 Replies

Convert Excel 2007 Macro Code To Correct VB 2008 Code?

May 26, 2010

i recorded the following macro in excel 2007:

[Code]...

View 3 Replies

COM Server Code Way Slower Than Excel VBA Code?

Sep 1, 2009

I have a client who needs Excel VBA code that produces formula values moved to VB.NET. He is in the business of providing financial analytics, in this case delivered as an Excel add-in. I have translated the VBA into VB.NET code that runs in a separate DLL. The DLL is compiled as a COM Server because, well, Excel-callable .NET UDFs have to be. So far, so good: Excel cells have "=foo(Range1, Range2, ...)", the VB.NET Com Server's UDF is called, and the cell obtains a value that matches the VBA code's value.

View 7 Replies

What Is These Two Lines Of Code Saying

Mar 8, 2011

Seems begineer but i really do not understand what these lines of code saying, since I'm kinda like newbie in datatable and dataview or such stuff! [code]).DefaultView.Count = 0 Then EncodeToText will encoed the text given from DESCRIPTION field in the database and convert it to string. So it is filtering it but only certain description fields, how ever by some strange reasons that second line is not working properly.

View 1 Replies

Change A Few Lines Of Code From CS.NET To .NET?

Mar 23, 2011

Basically I'm trying convert the following....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

[code]....

View 3 Replies

Comment Out Lines Of XML Code Through VB?

Jun 16, 2011

When reading and writing data to an XML file, in XML code, through a VB application, how does one go about commenting out a specific XML code line? From what I've gathered the original <!-- and --> tags aren't compatible. So what would be the VB alternative? Or is it just not possible to comment out a line of XML code using XML code through VB?

View 5 Replies

Converting C# To Vb 3 Lines Of Code?

Jan 2, 2012

i'm making a console program that consults a website of my work but it uses https and has a Untrusted certificate so i get this error: This Connection is Untrusted i did some research on the internet about this issue and come up with this code

//for testing purpose only, accept any dodgy certificate. public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)

[Code]...

View 6 Replies

Entering Last And First Name With Only 2 Lines Of Code?

Feb 5, 2012

I am a beginner trying to create a console program that lets the user enter a last name, then a first name with only 2 lines of code. The program should then display the first name followed by the last name.

I know how to do this, just not in 2 lines of code.

View 9 Replies

Lines Of Code In VB Project

Aug 7, 2009

What is the easiest/simplest way of finding out the number of lines in your VB project?

View 4 Replies

Splitting Code Into Two Lines?

Apr 12, 2010

I have a long line of code and I would like to split it into two lines. I've tried using , _ and & _ but they did not work.

Here is the

vb.net
If c < 1 Or c > 9 Or a = c Or b = c Or a = b Or occupied(b) <> occupiedEnum.empty Or occupied(c) <> occupiedEnum.empty Then

View 6 Replies

Way To Reduce Lines In Code?

Jan 25, 2010

I have a school project. by selecting an item from combobox it will show 2 pictures and 2 labels. I used a select case first but it didn't work; only for the first item ;do i have to make every pictures and labels invisible which are 30 controls and repeat it in every index? I try the if else but it did not work too.[cod]

View 4 Replies

C# - Insert Some Lines Of Code To Other Projects?

Mar 14, 2011

i have one project (let's call it project1) that is going to add properties to another project's class. The thing is I wanted to make it automatically. So in my project there are two lines of code which I want to add at the bottom of the class.vb or class.cs in a project called project2. Is it possible? If so, how?It is a data access builder software which after adding some new columns to our database we use it to generate its properties and its parameter to be added in BLL. Since we do it often (changing our database structure) I did not wanted to copy data from data access builder software and add it to project2 manually.

View 3 Replies

C# - What Happens If Add Lines To IL Code And Add Breakpoints To Program

Aug 8, 2009

If I add let's say 1 line at the beggining of a method, if I set a breakpoint through Visual Studio on the first line, will it point to the first line or the second? If it will flag the wrong line, is there anything we could do when editing .exe files to ensure a regular debugging session later?Isn't there something like setting line x to be Y? I remember seeing something like that somewhere, not sure if .NET related or not.

View 4 Replies

How To Find Lines Of Code In VS 2010

Jun 8, 2011

How to find Lines of Code in VS 2010?

View 7 Replies

Make A Pause Between Code Lines?

Mar 4, 2009

How do I make a pause between code lines? See code below. This just prints the word "Hello", I was hoping to put a delay between the letters to make it look more real. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click

SendKeys.Send("%{tab}") SendKeys.Send("H") SendKeys.Send("e") SendKeys.Send("l") SendKeys.Send("l") SendKeys.Send("o")
End Sub

View 3 Replies

Record All Lines Of Code Being Executed?

Aug 15, 2011

I have a form that on load keeps closing without any errors... I have no clue what it wrong with it. How can I record all the lines of code being executed so that I can find out why it is closing. There are no errors or me.closes.

View 3 Replies

Code To Load The Already Compiled Yahoo Files To Execute The Code Again, Without Having To Recompile The Code?

Dec 8, 2011

I have some code to execute code at runtime...

Here is the main

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If TextBox1.Text.Trim <> "" Then
If TextBox2.Text.Trim <> "" Then

[code]....

When the button is pressed, it all works and the following files are created: yahoo.dll and yahoo.pdb My question is this: What is the code to load the already compiled yahoo files to execute the code again, without having to recompile the code?

View 1 Replies

Code For Drawing Multiple Lines On Form?

Jun 5, 2011

I want to draw three straight lines on a form. if the following code is correct:

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim Line1 As System.Drawing.Graphics

[CODE]........

Can I use only one variable (Line1) to draw three straight lines?

View 2 Replies

Count The Total Number Of Lines Of Code?

Dec 29, 2009

i wrote an application in VB.NET and since i charge by the line, i would like to calculate how many lines i wrote. i have about 100 different vb files with my code. how do i count all the lines?

View 8 Replies

How To Hard Code Multiple Lines In A Richtextbox

May 18, 2010

I am attempting to hard code a richtextbox that has multiline characters upon the Load_Event. However, whenever I use the "&controlchars.newline _ " I get a syntax error and end of statement expected error.

[Code]...

View 3 Replies

Ignoring Lines Containing Certain Numbers (Code Included)?

Dec 3, 2009

Basically I want to have a lines that contain certain numbers ignored. Where lines that do not contain those certain numbers show up in textbox1.text.For Instance.In the code I want it to ignore all lines that contain "1234" and "1645" when it reads Accessed.txt, and output every line that does not contain those numbers. So if a line contains "78910" it would output that line into textbox1.text.Here is what I have so far, and it works as long as I only have 1 if not contains statement. When I have more than one, it doesn't work at all and just outputs everything in the text file.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim r As New System.IO.StreamReader("S:accessed.txt")

[code].....

View 5 Replies

Moving Lines In Code Of A Program While Running

Oct 27, 2011

I want to go back to the input line in the four places in the code that say something like strinputmessage = strnegative or strinputmessage = strnonnumeric.I need to be able to go back to where you input the data so that the index does not increase.I tried using a GoTo <23> to go back up to the line i needed but then it gave me all these weird errors about the End and Next were missing.[code]

View 3 Replies

Size Projects With About 100k Lines Of Code?

Feb 11, 2010

I recently inherited a nice size projects with about 100k lines of code and would like to find out what code is actually being run. I've found a number of routines that are not called at all and looking for a fast and automated way to explore the Business Layer to see what other code can be refactored out quickly.

This is an ASP.NET website with VB.NET codebehind and Business Layer.

View 4 Replies

Zip Code Is Dropping Leading Zero When Displayed On Excel. Export To Excel From XML To XSLT Transform?

Aug 16, 2010

I am exporting data from vb.net to excel and it is dropping the leading zero when its displayed on excel. How can I avoid the dropping of leading zero? I read the solution of adding a single quote but it makes my excel sheet column ugly. Also users will complain if they see a single quote on zip code field.vb.net code

Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""

the stored procedure outputs XML and it is transformed by XSLT before it is displayed on EXCEL

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<HTML>

[code]....

adding a single quote or manipulating excel sheet with column formatter (general/numbers ) etc. I don't want user to make any changes on excel to get the display properly when the excel is displayed from web page it should be all set with proper formatting. also we have no control over client excel software?

View 4 Replies

Office Automation :: Code Hangs When An Excel File Is Opened To A Excel Workbook Object?

Aug 3, 2009

I use the following code snippet

Dim exlapp As New Microsoft.Office.Interop.Excel.Application
Dim xlWorkBook_new As Microsoft.Office.Interop.Excel.Workbook
Dim strOriginal As String
strOriginal = Server.MapPath(Request.ApplicationPath & "/Attachments/") & "abc.xls"
xlWorkBook_new = exlapp.Workbooks.Open(strOriginal)

The code hangs in the last line. It works fine in the development environment. i deployed in windows server 2000 ,where I get this issue. the browser goes half way and throws the below exception after some time

[Code]...

I have set the identity impersonate to true in web config. This should be mostly an access rights issue.I have even provided access rights for the "everyone " user in the excel file and as well for the interop component. Please post ur valuable comments.

View 3 Replies

Excel VBA Code Waits Indefinitely When Excel Window Is Not Active

Sep 7, 2010

I have one excel sheet which has ontime event of 5 mins to run some code.This code works fine when in debugging mode. But if I lock my PC or minimize excel windows and start working something else, this code just pauses at beginning and as soon as I activate excel window, this code runs.this code involves opening and closing of one userform and i think userform is culprit.

View 2 Replies

VS 2008 : Use Code To Read Excel File With Excel Installed?

Feb 7, 2012

I am uploading an excel file to my app and want to read it. Do I need to have excel loaded to read this?I am getting an error of Object reference not set to an instance of an object.

Public Function GetExcelData(ByVal ExcelFilePath As String) As DataTable
Try
Dim OledbConnectionString As String = String.Empty

[code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved