Thread: help with vbasic program

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    32

    help with vbasic program

    yes im using gay visual basic to write a program. someone is paying me for the source and he said he wanted it to be done in visual basic. i just need to know how i can using a binch of variables with assigned numbers be used into a excel document
    Silent to All
    -Those who live by the sword get shot by those who don't.

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    VB! The devil! No!

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    32
    thats wut i sed but hey i getting paid and i need money
    Silent to All
    -Those who live by the sword get shot by those who don't.

  4. #4
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Can you elaborate on the problem, i did alot in VB and i can prolly help out.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Truth is a malleable commodity - Dick Cheney

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    32
    bassicly im making a stats keeping program for a voleyball team at a gym which the guy wants to be made in vbasic so he can later edit anything he might need to. each stat of each player like how many serves is held in a varibale and how many succfull serves in another. and so on for each player (theres more stats then that to keep) and i want to have a button to use all the numbers form the variables to be in a excel table. well thats what he wants to happen. is this possible?
    Silent to All
    -Those who live by the sword get shot by those who don't.

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by TheUnheardHuman
    bassicly im making a stats keeping program for a voleyball team at a gym which the guy wants to be made in vbasic so he can later edit anything he might need to. each stat of each player like how many serves is held in a varibale and how many succfull serves in another. and so on for each player (theres more stats then that to keep) and i want to have a button to use all the numbers form the variables to be in a excel table. well thats what he wants to happen. is this possible?
    Its not too difficult...you need to include the library for your version of Excel in the reference settings...then do something like

    Code:
    Private Sub Form_Load()
    On Error GoTo err_handler
        Dim oApp As Excel.Application
        Dim oWkBk As Excel.Worksheet
        
        Set oApp = New Excel.Application 'Open Excel
        
        oApp.Visible = True 'Make it visible
        
        oApp.Workbooks.Add 'Add a new sheet
        Set oWkBk = oApp.ActiveSheet 'Create reference to new sheet
        
        oWkBk.Range("A1").Value = "Forename" 'Set column names
        oWkBk.Range("B1").Value = "Score"
        oWkBk.Range("A2").Value = "Dave" 'Set Data
        oWkBk.Range("B2").Value = 40
        oWkBk.Range("A3").Value = "Andrew"
        oWkBk.Range("B3").Value = 35
        oWkBk.Range("A4").Value = "Simon"
        oWkBk.Range("B4").Value = 29
        
        Set oWkBk = Nothing
        Set oApp = Nothing
        Exit Sub
        
    err_handler: 'if error
        MsgBox Err.Description
    End Sub
    Or even with VC++

    Code:
    #pragma warning (disable:4146)
    //I am assuming you have a setting under Tools->Options->Directories
    //For "Program Files\Common Files\Microsoft Shared"
    //And the Office folder (wherever it is)
    #import "Office10\mso.dll"
    #import "VBA\VBA6\VBE6EXT.olb"
    #import "excel.exe" \
    	rename("DialogBox", "ExDialogBox") rename("RGB", "ExRGB")
    
    #include <windows.h>
    #include <iostream>
    
    struct COMINIT{//Start and end COM
    	COMINIT(){CoInitialize(0);}
    	~COMINIT(){CoUninitialize();}
    }CI;
    
    inline std::ostream& operator<<(std::ostream& out,
    	const _bstr_t& str){//Just to stop having to cast to Char*
    	out << static_cast<char*>(str);
    	return out;
    }
    
    
    int main(){
    
    	try{
    		Excel::_ApplicationPtr lpApp("Excel.Application");
    		Excel::_WorksheetPtr lpWkst = 0;
    		
    		lpApp->PutVisible(0,TRUE);
    
    		lpApp->Workbooks->Add();
    		lpWkst = lpApp->ActiveSheet;
    
    		lpWkst->Range["A1"]->Value2 = "Forename";
    		lpWkst->Range["B1"]->Value2 = "Score";
    		lpWkst->Range["A2"]->Value2 = "Dave"; 
    		lpWkst->Range["B2"]->Value2 = 40L;
    		lpWkst->Range["A3"]->Value2 = "Andrew";
    		lpWkst->Range["B3"]->Value2 = 35L;
    		lpWkst->Range["A4"]->Value2 = "Simon";
    		lpWkst->Range["B4"]->Value2 = 29L;
    
    		lpWkst = 0;
    		lpApp = 0;
    
    	}
    	catch(_com_error& e){
    
    		std::cout << "Error ";
    		std::cout << (e.Description().length() ? e.Description() : "");
    		return 1;
    	}
    	return 0;
    }
    (Both Assume ExcelXP)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM