|
Mark,
Try this:
http://support.microsoft.com/kb/198571[^]
The article is for Access 2000, but the code would be very similar.
(Without the Set statements of course.)
objExcel.Application.Run("atpvbaen.xla!lcm", 5, 2)
Dave
|
|
|
|
|
I want to pass the name of a worksheet to the Sheets.Select(name) function. I defined a public variable in the worksheet declaration and assigned the name to the sheet I want to select. I am getting an error subscript out of range.
Any suggestions. (is this possible?)
Jude
|
|
|
|
|
TheJudeDude wrote: (is this possible?)
Sure.
Make sure the variable actually contains the name, make sure it is spelled correctly, and be specific as to which WORKBOOK you are referencing the Sheets collection in.
But do you want to select the sheet or replace ranges on it?
If you want to select the sheet, it's like this:
Ex.
Public Sub TestWBname()
Dim wb As Workbook
Dim wbName As String
Application.Workbooks("Book1").Activate
Set wb = Application.ActiveWorkbook
wbName = "mySheet"
wb.Sheets(wbName).Select
End Sub
There's a Sheets.Select([Replace]) function, which uses the syntax you specified above, but which I don't think is what you want.
|
|
|
|
|
You dont give the sheet name to the Select method. You give it to the Items property of the Sheets collection, which will return a Worksheet object, on which you call the Select method.
Sheets("Sheetname").Select()
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
1) I know this is an ASP.NET question, but the answer rate in that particulary forum is far behind this forum.
Q)The index page on a website i'm designing contains a menu for, well, navigation. My question is what is the best route to dynamically set the menu's SiteMapProvider to the correct provider based on a users login credentials.
Nathan Lindley
|
|
|
|
|
I'm trying to detect whether someone has Insert on/off, but the code I'm using isn't working.
<br />
If Keys.Insert = True Then<br />
Label.Text = "Overwrite"<br />
End If<br />
If Keys.Insert = False Then<br />
Label.Text = "Insert"<br />
End If<br />
Please help. Thank you!
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
Standard question #2:
What error message do you get?
Of course it isn't working. Keys is a enumeration that contains values for key codes. The value Keys.Insert is a constant value which can never be True, neither False, at it is not a boolean value.
You should get an error message from the compiler, saying that the value of the condition could never change, as you are comparing two constant values.
---
b { font-weight: normal; }
|
|
|
|
|
I do not get an error message or compiler error, it just doesn't change the label's text like I want it to.
And, what should I use instead of Keys or Keys.Insert ?
|
|
|
|
|
I don't think there is a true dotnet way.
use this api
Private Declare Auto Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As VirtualKey _
) As Boolean
google it to find out how to use it...
|
|
|
|
|
Sorry, doesn't work. Thanks anyway though!
|
|
|
|
|
The api code definition was written Pre-dotnet so it uses long and integer. you need to change these to the new dotnet equivalents to int32 / int16.
just tested the below code in 2005 and it works fine:
Public Declare Function GetKeyState Lib "user32" Alias "GetKeyState" (ByVal nVirtKey As Int32) As Int16
private sub CheckInsertStatus()
if getkeystate(keys.insert)=0 then
msgbox "overwrite"
else
msgbox "insert"
end if
end sub
|
|
|
|
|
It works! Thanks a lot dude!
|
|
|
|
|
I have my program check the command line arguments for the "/s", "/c" and "/p" arguments, which works perfectly fine until I build the solution and change the ".exe" to ".scr". After that they don't work at all. It just goes to the default form. Am I doing something wrong? Can someone please help?
______________________________
Wake up and smell the ashes...
|
|
|
|
|
Is there a way to make a vb.net project (solution) so that multiple end-users can use it at the same time ???
Thanks in advanced
Silver-grey
silver-gray
|
|
|
|
|
If you're talking about multiple developers writing code in the same solution, then yes, there is. You have to have either Visual Source Safe installed (VS.NET 2002 and 2003) or one of the Visual Studio Team System versions installed (VS.NET 2005) with Team Server installed. Or, some other third party source control solution. This will manage file checkouts and checkins so multiple developers can work on different parts of the solution at the same time.
Or were you asking how to write a multi-user app?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
multi user app
silver-gray
|
|
|
|
|
That depends on what you mean my a "multi-user app"? Since Windows is a single user O/S, every instance of the app doesn't know about any other instance that's running, so I don't get you mean by "how do you do this?"
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Several pcs that have the same Software application (VB.NET) all using Access on one server. This is multi-user. This happens in mainframe (CICS) and also in pcs.
silver-gray
|
|
|
|
|
Each PC will run its own instance/instances of the app. It's up to you as the developer to provide the app the ability to communicate with the database on the server. Using Access as a database is a real pain (and it's also limited to a 2GB file size), and as such I'd recommend using SQL Server.
Also, ADO.NET uses a disconnected data object model in that the app does not persist any connection to the database - it connects, retrieves data & disconnects. This allows your apps to be far more scalable however, concurrency of records then becomes an issue.
Learning ADO.NET[^]
Introduction to Data Concurrency in ADO.NET[^]
|
|
|
|
|
when printing in vb.net, i can prevent my application from showing this little form, which says 'generating document, preparing page 1 for printing" (or whatever it says) by using a new printcontroller:
<br />
PrintDocument1.printController= new Printing.StandardprintController<br />
but when i use printpreviewdialog or printpreviewcontrol to show the preview, the little form appears again. How can i prevent that?
|
|
|
|
|
using vb.net (2002) to read data from a binary file written by a legacy vb6 application (that I have the code for).
The data is of various types and is held in a structure.
I've simplified it below
Private Type QuoteInfo
sngCashOption As Single
... other variables of other types ...
strName as String
strAddress as string
End Type
Private muQuote As QuoteInfo
muQuote is then filled with data and then saved thus:
Open strFileName For Random As iFileNo Len = 500 ' Len(muQuote)
Put #iFileNo, miRECORD_NO, muQuote
Close iFileNo
Now the types aren't the same in vb6 and .NET - I've had to change Long in to Int32 and so on, but my problem is with strings
My .NET for reading it is:
Private Structure QuoteInfo
Public sngCashOption As Single
... other variables of other types ...
Public strName as String
Public strAddress as string
End Structure
Dim qi As New QuoteInfo()
Dim fs As FileStream = File.Open("filename", FileMode.Open)
Dim binRead As New BinaryReader(fs)
qi.sngCashOption = binRead.ReadSingle
... other variables of other types ...
qi.strName = binRead.ReadString
qi.strAddress = binRead.ReadString
And I get an 'System.IO.EndOfStreamException' when I try and read the second string. Any ideas? I guess strings are held differently.
Any ideas?
Thanks in Advance - Ben
|
|
|
|
|
Almost all of my textboxes in my application I am building have a waitcursor property and when I try to change it, I click on the Ibeam selection but it doesnt change. The waitcursor remains. I tried changing it in code on my FormLoad event and this didnt work. There are some textboxes that do not have this issue but MOST of them do which makes this even more wierd. And also if I make a new textbox it will by default have the Ibeam property but when I compile and put my cursor over it, it has the WaitCursor!!!!!! I have spoken with several other programmers in the building and none can figure out what to do about this. I am just trying to find someone who has had a similar problem and fixed it or someone who has an alternate idea of what I can do about this (besides Re-installing VS). I am using Visual Studio 2005. Thank you in advance for your responses...
|
|
|
|
|
I've never seen the problem. You might want to check the designer generated code to see if it has been specified somehow. Other than that, I've never even heard of someone having this problem.
Are you creating the textboxes on another thread maybe? (Just grasping at straws here...)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks for the help.... I am new to vb.net 2005 and I cannot seem to figure out how to view the designer generated code. It isnt in the code view like it is in .net 2003. Is there a way to toggle the form generated code visible and not???
|
|
|
|
|
There's an icon in the Solution Explorer window that is labeled (hover the mouse of each icon) "Show All Files". I think it's the second one from the left side. Each form file will then get a little plus next to it. It think you can figure it out from there...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|