Jump to content

C++ or VBA


Costinbos77

Recommended Posts

Hi there,

 

I want to make an executable program (. exe) and with a form (window) that contains some buttons and an Excel cell area (13 columns and rows variables that I fill them by the method copy / paste).

 

What programming language would be easier to learn : C++ or VBA?

I work only with LISP (ActiveX).

 

 

Thanks in advance.

Link to comment
Share on other sites

I can't say anything about C++ but I don't think you can make an exe using VBA. VBA is a sub set of Visual BASIC and needs to live within another application, AutoCAD, Word, excel etc. If you are considering learning something else to assist with AutoCAD I would avoid VBA as it is no longer supported out of the box. It can be enabled with a free download but that suggests less support than previous. Visual Basic will allow you to make an exe but that has been superceded by VB.Net. I am currently trying to learn VB.Net so can't comment on its effectiveness in your situation but it does appear to be worth learning.

Link to comment
Share on other sites

Thanks for the reply. I read a bit of manual C + +, but it is very difficult.

Killing me syntax and declaring functions and variables.

Link to comment
Share on other sites

The tool may also be Excel based, that it, a macro - this may be designed in VBA or VSTA (Visual Studio Tools for Applications).

If you need a stand-alone tool (executable) that will access Excel and control the worksheet, then I suggest you to look on one language from .Net pack, either VB or C# (sharp). You will find a lot of already developed code on the Internet for your project. C++ is quite difficult to master.

Link to comment
Share on other sites

I want to make a program to import the idx file (text) in a special format:

 

 

 

HEADER

....

SEPARATOR ','

....

END HEADER

 

DATABASE

POINTS (PointNo,PointID,Code,East,North,Elevation,CLASS)

1, "Bo S 1", "", 553417.1840, 337149.5610, 87.0430, FIX;

2, "Bo S 2", "", 553419.5750, 337147.0930, 87.0350, FIX;

3, "Bo S 3", "", 553424.4660, 337150.1440, 86.8700, FIX;

4, "Bo S 4", "", 553427.7610, 337153.3130, 86.8700, FIX;

5, "Bo D 1", "", 553440.2180, 337133.9800, 86.7730, FIX;

....

THEMINFO (PointNo,PointID,Attribute,Value)

1, "Bo S 1", "Info 1", "";

1, "Bo S 1", "Info 2", "";

1, "Bo S 1", "Info 3", "";

1, "Bo S 1", "Info 4", "";

1, "Bo S 1", "Info 5", "";

1, "Bo S 1", "Info 6", "";

1, "Bo S 1", "Info 7", "";

1, "Bo S 1", "Info 8", "";

2, "Bo S 2", "Info 1", "";

2, "Bo S 2", "Info 2", "";

2, "Bo S 2", "Info 3", "";

2, "Bo S 2", "Info 4", "";

2, "Bo S 2", "Info 5", "";

2, "Bo S 2", "Info 6", "";

2, "Bo S 2", "Info 7", "";

2, "Bo S 2", "Info 8", "";

3, "Bo S 3", "Info 1", "";

3, "Bo S 3", "Info 2", "";

3, "Bo S 3", "Info 3", "";

3, "Bo S 3", "Info 4", "";

3, "Bo S 3", "Info 5", "";

3, "Bo S 3", "Info 6", "";

3, "Bo S 3", "Info 7", "";

3, "Bo S 3", "Info 8", "";

4, "Bo S 4", "Info 1", "";

4, "Bo S 4", "Info 2", "";

4, "Bo S 4", "Info 3", "";

4, "Bo S 4", "Info 4", "";

4, "Bo S 4", "Info 5", "";

4, "Bo S 4", "Info 6", "";

4, "Bo S 4", "Info 7", "";

4, "Bo S 4", "Info 8", "";

5, "Bo D 1", "Info 1", "";

5, "Bo D 1", "Info 2", "";

5, "Bo D 1", "Info 3", "";

5, "Bo D 1", "Info 4", "";

5, "Bo D 1", "Info 5", "";

5, "Bo D 1", "Info 6", "";

5, "Bo D 1", "Info 7", "";

5, "Bo D 1", "Info 8", "";

 

....

 

END THEMINFO

END POINTS

END DATABASE

 

 

After reading the file, the data columns to arrange the cell window.

Here I would like to be able to add or delete rows with information.

 

Finally, you can save especially .idx format.

 

I do not think it works in Excel.

Edited by Costinbos77
Link to comment
Share on other sites

I agree with MSasu. If you want to read portions of the .idx file into Excel for editing and saving then the language to use is either

  • the VBA already within Excel
  • .NET - either C# or VB

Either environment will let you create a form and hook events to buttons. You'd need at least one button event to open the file and populate the table and another to export the edited result.

 

If this is for your own use or within your office, Excel VBA is the easier choice.

If you are hoping to sell, .NET will let you cut a .exe and sign it.

 

I'd stay well away from C++ for this.

 

hth

 

Hugh Adamson

www.hatchkit.com.au

Link to comment
Share on other sites

Download the free copy of Microsoft Visual Studio as a starting point. This replaced the older Visual basic compiler VB6 etc but now with emphasis on .net.

 

Dbroada you can make exe from VBA just have to use the correct compiler. I gave up on Visual studio to much to learn to old now, but I know you can import VBA into it and compile.

Link to comment
Share on other sites

Thanks guys for your answers.

 

I have discussed with other friends and the conclusion was the same:

 

- the VBA already within Excel

- Import from Excel properties and creating of the form (NO DCL) in AutoCAD through VBA;

- .NET - either C# or VB

 

Link to comment
Share on other sites

As BIGAL noted, there is a free version for .Net pack's components. Just search VB.Net or C#.Net Express - after installed will require registration to be activated. However, if I remember well, the usage for bussines purposes isn't allowed.

Link to comment
Share on other sites

I started writing something in VBA from Excel already, is reasonable.

 

 


Sub LoadIDX()
   Dim aSheet As Worksheet
   Dim lngLastRow As Long, lngLastCol As Long
   Dim i, j, k, l As Integer
   Dim st, en, st1, en1 As Boolean
   Dim spli() As String
   Dim MyDate
   MyDate = Date    ' MyDate contains the current system date.

   aIDXfile = ThisWorkbook.Application.GetOpenFileName("IDX File to Open(*.idx),*.idx")
   If aIDXfile = False Then
      Exit Sub
   End If

ActiveSheet.PageSetup.CenterHeader = "&D  &B&ITime:&I&B&T"
  ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count) ' xlWorksheet ' Add New Sheet
  Set aSheet = ThisWorkbook.ActiveSheet
     aSheet.Activate
   Cells(1, 1).Interior.ColorIndex = 3 ' Culoare Celula
'    Range(Cells(1, 1), Cells(Rows.Count, Columns.Count)).Value = ""
'    Range(Cells(1, 1), Cells(Rows.Count, Columns.Count)).Borders.LineStyle = xlNone
'    Range(Cells(1, 1), Cells(Rows.Count, Columns.Count)).Interior.ColorIndex = 0

   aSheet.Cells(3, 4) = "Data :"
   Cells(3, 4).Font.ColorIndex = 3
   aSheet.Cells(3, 5) = Format(Date, "yyyy.mm.dd/") + Format(Time, "hh.mm.ss") 'Date
   Cells(3, 5).Font.ColorIndex = 3 ' 3=Rosu , 1=Negru

   aSheet.Cells(2, 2) = "Fisierul :"
   Cells(2, 2).Font.ColorIndex = 4 ' 4=Verde , 1=Negru
   aSheet.Cells(2, 3) = aIDXfile
   aSheet.Cells(4, 1) = "ID"
   aSheet.Cells(4, 2) = "Nume"
   aSheet.Cells(4, 3) = "Est [ m ]"
   aSheet.Cells(4, 4) = "Nord [ m ]"
   aSheet.Cells(4, 5) = "Cota [ m ]"
   aSheet.Cells(4, 6) = "Cod"

   l = 1
   While l < 9
   aSheet.Cells(4, l + 6) = "Atribut " + Format(l)
   l = l + 1
   Wend    ' End While loop when Count

   ActiveWindow.SplitRow = 3.5 ' Impartire Pagina
   Open aIDXfile For Input As #1    ' Open file for input.
i = 5
st = False
en = False
Do While Not EOF(1)    ' Loop until end of file.
   Line Input #1, mystring
   mystring = LTrim(mystring)

  If Left(mystring,  = "THEMINFO" Then
        en = True
  End If
   If st And en = False Then
        spli = Split(mystring, ",")
        Cod = spli(2)
'         For j = 1 To UBound(spli) '+ 1
'           vastr = Replace(spli(j - 1), Chr(34), "")
'           vastr = Replace(vastr, ";", "")
'           aSheet.Cells(i, j).Value = vastr
          aSheet.Cells(i, 1).Value = spli(0) ' Nr
          aSheet.Cells(i, 2).Value = spli(1) ' Nm
          aSheet.Cells(i, 3).Value = spli(3) ' E
          aSheet.Cells(i, 4).Value = spli(4) ' N
          aSheet.Cells(i, 5).Value = spli(5) ' Z
         If Cod <> "" Then
          aSheet.Cells(i, 6).Value = Cod
         End If ' Cod
'         Next j
        i = i + 1
   End If
  If Left(mystring, 6) = "POINTS" Then
        st = True
  End If

Loop
Close #1
lngLastRow = aSheet.Cells(Rows.Count, 2).End(xlUp).Row
lngLastCol = aSheet.Cells(4, 2).End(xlToRight).Column
Set RangeMax = Range(Cells(4, 1), Cells(lngLastRow, lngLastCol))
RangeMax.Borders.LineStyle = xlContinuous
Range(Cells(4, 1), Cells(4, lngLastCol)).Interior.Color = RGB(200, 200, 255)
Range(Cells(5, 1), Cells(lngLastRow, 1)).Interior.Color = RGB(240, 240, 240)
'Range(Cells(5, 3), Cells(lngLastRow, 5)) = Format(Format, "###0.00")
Range(Cells(3, 1), Cells(lngLastRow, lngLastCol)).Columns.AutoFit
Range("B5").Select
End Sub
'    "Point ID" "Point Name" "Esting" "Northing" "Elevation" "Code"


 

Follow the export data

 

How to set the number of decimal places in Format Cell?

 

How call a text file for writing?

 

Thanks guys !

Link to comment
Share on other sites

  • 2 weeks later...
As BIGAL noted, there is a free version for .Net pack's components. Just search VB.Net or C#.Net Express - after installed will require registration to be activated. However, if I remember well, the usage for bussines purposes isn't allowed.

 

As I understand the EULA with the "Free" versions of Visual Studio, you can use it at work. But if you start commercially selling the software you develop with it, then our friends in Redmond, WA will want their cut of your profits and for that you will need to purchase the full package.

Link to comment
Share on other sites

You don't have to pay M$ anything, simply register your VSE installation. :thumbsup:

 

From: http://stackoverflow.com/questions/11376472/which-version-of-visual-studio-can-i-use-for-commercial-project

 

Express editions allow creating projects that you sell.

 

The VS 2010 Express EULA makes no restrictions to commercial use of either it, or any software created using it.

 

The Redistribute Code listing for Visual Studio 2012 RC makes no such restrictions, providing that your specific licence agreement also doesn't.

 

The Visual Studio 2010 Ultimate with MSDN licensing details similarly mention no restrictions on commercial (or web hosting) use, and not mention of any exceptions for a student licence.

 

Also: http://programmers.stackexchange.com/questions/97401/how-much-should-i-pay-to-microsoft-when-i-am-selling-a-desktop-software-built-on

Link to comment
Share on other sites

Aha, I knew Renderman would come through for us on this. I use VB 2010 Express and VS 2012 Express at work. While I don't resell my software, I do get paid to develop it for this client. That is good news to confirm. I really like working with VS and intend to continue doing so for the foreseeable future.

Link to comment
Share on other sites

Aha, I knew Renderman would come through for us on this.

 

Cheers dude. :beer:

 

Most .NET developers have the essentials to work indepentantly using Visual Studio Express (VSE, i.e., C#,C++,VB 2010, or Windows Desktop 2012, etc.)... As most of what one might develop using VSE functions indepentantly. For those apps that are dependent on other Microsoft technologies, it is incumbant upon the would-be client to purchase those technologies.

 

The only limitation I've run into (coming from an Autodesk development side of things), is that I required full version VS in order to develop plug-ins for Office products via VSTO.

 

Other than that, I do all of my Autodesk development (AutoCAD, Map 3D, and Civil 3D, WPF Browser Apps, etc.) using VSE 2010 for work (using my work laptop), and VSE 2012 at home for to-sell products (using my home laptops)... Still setting up the website, and preparing the Autodesk Exchange products as free time permits.

Link to comment
Share on other sites

Don't what I did wrong -- but downloaded the free version -- I lost everything on the hard drive. Took me 2-1/2 days to get up and running again. The recovery disk I had with the computer only had the basic windows on it none of the Microsoft programs etc.

Link to comment
Share on other sites

dbroda:

How is vb.net going for you? I wrote a program in vb 6 and loved writing code. I was actually therapuetic. I have since moved over to C# but the learning curve for the dot net framework is pretty damn steep. The biggest hurdle for me is seeing the big picture related to OOP. I tend to think in terms of functions and the concept of objects has been difficult to implement. In theory, they are pretty straight forward...that is until you sit down to write some code.

 

I wrote a tank level simulation program in vb.net without the benefit of oop. Now, since I have a working program, I am trying to rethink it in terms of objects. I would love to discuss programming with you if you ever want to.

My program is online at www.squirtonsite.com if you care to take a look.

Link to comment
Share on other sites

I have the Jerry Winter(?) book and am slowly going through it. So far nothing that new but I now have too much project work to pick it up ATM. Should be back on it in a couple of weeks time, which will probably mean starting again. I don't retain things as well as I used to - must be getting old.

Link to comment
Share on other sites

If I might attempt to save any whom may share similar pursuits of becoming adept at development with the .NET API, I very much learned the hard way that it's not easy transitioning from LISP ==> .NET, as the mindset of a LISP developer is fundamentally different.

 

In scope alone, LISP focuses on the the Document level (generally speaking), whereas .NET commonly has a starting point at the Application level... Especially so for per-Document data frameworks, Event-driven plug-ins, CommandMethods Methods, and even LispFunction Methods.

 

This was discussed quite recently in another forum, so please forgive the quote/link to this thread:

 

 

... I think you're () overlooking development concepts generally with what I presume to be unintentional 'Autodesk blinders' on. This is unfortunately very common when stepping up from LISP to .NET API.

 

Given Object Oriented development as a whole, despite growing with each release, the Autodesk .NET API is a very tiny, perhaps minuscule, arena of the former.

 

If your goal is to become a capable AutoCAD .NET developer, then it is an essential, yet implied task, that you (first?) become a capable .NET developer (i.e., Console, Windows Forms, WPF Browser Applications, etc. to list a few), as while not explicitly stated in all beginner AutoCAD .NET materials, it can easily be considered to be a prerequisite... Particularly as you spill over into more complex tasks, and frameworks.

 

There are many free resources out there (some of which are available directly from Visual Studio's Start Page), but if you'd like to find a book to read, and re-read again, I found Andrew Troelsen's Pro C# 2010 and the .NET 4 Platform to be useful... All +1700 pages of it.

 


 

Andrew's Pro C# 5.0 and the .NET 4.5 Platform is also available for those who may be interested... Perhaps for the 2014 product line? *not sure*

 

... [NDA Censorship]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...