|
You can still setup Modules in VB.NET, but I don't recommend it since it'll pollute your namespace with all public members and methods.
A better way to do it would be to create a Global class containing Shared (static in C#) member variables.
Public Class Globals
Public Shared UserID As Integer
' Shared constructor. Initializes shared member variables.
Shared Sub New()
UserID = -1
End Sub
End Class
You can now access your global variables like this...
Dim id As Integer = Globals.UserID
|
|
|
|
|
it's exactly what I want. Thank you so much.
WiL
|
|
|
|
|
where can i get flexgrid sample appiclation... How to (cellformat, cell can be clickable)... im using VB2005.net..
thank you... very much....
pls email me at welbertpm@hotmail.com
welbert
|
|
|
|
|
Why would you use the old flexgrid instead of a datagrid ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
im trying to develop a simple calendar system... that could post the number of days in the fixed column header at the same time another identifier to be post on the fixed row...
could it be possible to use datagrid with these settings? pls i really need your suggestions.. and i need some sample applications...
thanks...
Welbert
|
|
|
|
|
Yes, a DataGrid would be fine, and the web is full of samples, just google.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Dear VB6 friends,
Happy New Year to you!
If the number of items exceeds what can be displayed in the list box, scroll bars should automatically appear on the control. The user can then scroll up and down or left to right through the list. But only the vertical bar appears on my VB6 application.
Anyone knows how to fix it?
Joy Anne
|
|
|
|
|
Isn't there a property that you set to say if you want the hscroll bars ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Unfortunately, the VB6 ListBox control doesn't give you direct access to the horizontal scrollbar. The only way to show it is via Win32 API. It isn't pretty.
I must be feeling extra generous today.
Here's my code that allows you to display a horizontal scrollbar just wide enough to show all of the ListBox's contents. All you have to do is pass a ListBox reference into the UpdateHorizontalScrollbar() function after adding your strings. It'll setup the scrollbar for you. The ListBox won't automatically adjust the horizontal scrollbar after adding/modifying strings, so you must call it again when changes occur.
' Define win32 functions.
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
' Analyzes given listbox and displays a horizontal scroll bar if needed.
Public Sub UpdateHorizontalScrollbar(lstCtrl As ListBox)
Dim fMax As Single
Dim fValue As Single
Dim iIndex As Integer
' Get length of longest text in listbox.
fMax = 0
For iIndex = (lstCtrl.ListCount - 1) To 0 Step -1
fValue = TextWidth(lstCtrl.List(iIndex))
If (fValue > fMax) Then fMax = fValue
Next
' Convert max text length to pixels.
fMax = fMax / Screen.TwipsPerPixelX
' Increase length for checkboxes and margins (in pixels).
If (1 = lstCtrl.Style) Then fMax = fMax + 13 ' Offset for checkbox.
fMax = fMax + 4 ' Offset for margins.
' Set horizontal scrollbar length.
SendMessage lstCtrl.hWnd, &H194, CLng(fMax) + 1, 0&
End Sub
|
|
|
|
|
in the form1 i declared an object of form2 "objfrm2".
then i called objfrm2.
now i want to call form one (the one who called objrm2) without using a mid-hand like a module (which includes to objects one of frm1 and the other frm2).
is that possible
Militiaware
Faris Madi
|
|
|
|
|
We need a VB.NET FAQ.
The best way is the use a delegate between the two classes, the other way is to have a variable of type Form1 within Form2, and have the only visible constructor take a Form1 instance so it can be set. The other solution is to define an interface which defines the methods that Form2 needs to call on Form1, and have Form1 define the interface, Form2 store an instance of it. Just passing Form1 to Form2 is the ugliest solution, but also the quickest,
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I want to have a string of the selected install directory, putting this in the AfterInstall method. I need to use the path for doing something with registry but not sure how to get it.
TIA,
Brian
|
|
|
|
|
ok, problem solved,
Right Click installer project, View, Custom Actions
click on the Install method, put /targ="[TARGETDIR]\" into CustomActionData field
and put this into afterinstall method (displays directory in a message box)
<br />
Dim stringD As System.Collections.Specialized.StringDictionary<br />
stringD = Me.Context.Parameters<br />
<br />
Dim enume As System.Collections.IEnumerator<br />
enume = stringD.Values.GetEnumerator()<br />
<br />
Dim directory As String<br />
enume.MoveNext()<br />
directory = enume.Current<br />
System.Windows.Forms.MessageBox.Show(directory)<br />
|
|
|
|
|
Hi All
I have a Microsoft Excel Add-in written in VBA. It includes a function that calls a .dll via a Declare statement along the lines of:
Declare Function SOMEFUNCTION Lib "c:\Program Files\SomeFunction.dll" (ByVal SomeNo as Double) as Double
Instead of including the full path to the Lib file such as "c:\Program Files\SomeFunction.dll", it is possible to register the SomeFunction.dll in the Windows Registry so that I can avoid the fiddly process of finding the path to the file so the Declare Statement becomes:
Declare Function SOMEFUNCTION Lib "SomeFunction.dll" (ByVal SomeNo as Double) as Double
Is that right? How do you register a .dll with Windows Registry? Is the REGEDIT.ex the only way? Is there some other way?
Any suggestions or thoughts on this would be much appreciated.
Thanks
JS
|
|
|
|
|
Well, VBA is a little limited in this respect. You can't register library .DLL's like you can COM .DLL's. Also, you can't change the location of your reference at runtime in VBA, so putting the path to the .DLL in the Registry isn't going to help much.
If you don't want to put the full path to the .DLL in your declaration, you're limited to putting the .DLL where it can be found without it.
The best place to put the .DLL is in the directory your code is launched from, usually in Program Files\myAppFolder. You could also put it in C:\WINDOWS, or more acurately, %SystemRoot%.
If your .DLL is not in the current directory, the loader then tries to find your .DLL in the each folder listed in the PATH environment variable. If it's not found in the PATH, your function call will fail miserably.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Many thanks Dave - That sheds much light - It's a shame that the Program Folder can't be reached as effortlessly as the Windows folder - Thanks again - JGS
|
|
|
|
|
Wanna bet? %ProgramFiles%
Try typing SET at a CMD prompt.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello everyone,
I'm having a hard time getting the hang of arrays in VB.Net. I'm trying to use one array to hold other arrays. Trick is, it will not always hold the parent array will not have a static number of child arrays. I'm trying to populate it something like this:
Dim ParentArray as Array<br />
Dim i, x as Integer<br />
<br />
'SQL query gets number of child arrays i want to make and assigns it to x<br />
<br />
for i = 0 to x<br />
ParentArray(i) = MakeChild(i)<br />
next
MakeChild returns and array, and goes a little something like this
Function MakeChild(ByVal QuestionID As Integer)<br />
Dim ansArray As Array<br />
Dim i As Integer<br />
<br />
strSQL = "sql query stuff"<br />
sqlCom = New SqlCommand(strSQL, sqlCon)<br />
drRes = sqlCom.ExecuteReader<br />
While drRes.Read() = True<br />
For i = 0 To drRes.Depth<br />
ansArray(i) = drRes(i)<br />
Next<br />
End While<br />
drRes.Close()<br />
Return ansArray
I keep getting the following error:
Object variable or With block variable not set
Sorry about the longish post. Any help would be greatly appreciated!
-------------------
abort, retry, fail?
|
|
|
|
|
First, you're not using arrays correctly. The following code does not create an array. It merely declares a reference to an Array initialized to Nothing.
Dim ansArray As Array
Arrays are defined like this...
Dim myNumbers(2) As Integer ' Creates an array with 3 elements.
Dim myYears() As Integer = {2000, 2005} ' Initializes a new array with 2 elements.
Looking at your MakeChild() code, you really shouldn't use an array. Arrays have a fixed size, meaning you have to determine how many rows will be returned from the database before you can allocate the array. Or you have to Redim the array on every pass in the loop, which is very inneficient.
Instead, you should use a data structure like the ArrayList which allows you to Add new elements to it. You could then Add the returned ArrayList to the parent's ArrayList.
Now about your error "Object variable or With block variable not set". That sounds like a separate coding error. Double click on the error message to find exactly where in your code this problem is occuring.
-- modified at 19:55 Tuesday 17th January, 2006
|
|
|
|
|
Thanks for your help! I'm pretty new to VB.Net and I guess I've picked up some misconceptions about arrays from some... sloppier languages I've been using for a while. But I changed the arrays to array lists and everything is behaving itself now.
Thanks again!
-------------------
abort, retry, fail?
|
|
|
|
|
Hi everyone,
I try to a display a .txt file in window's textbox or rich textbox. The text file has contents line by line aligned perfectly when using NotePad to view and print it. But when I display this .txt file in textbox or rich textbox the alignment all messed up. Please help me to solve this problem.
Thanks in advance.
nina
|
|
|
|
|
It's all messed up because your using the wrong type of font. In Notepad, you're always using a fixed-width font, like Lucida Console. Every character, and white-space character, is the same width.
By default, in a TextBox and RichTextBox, the font is a proportionally spaced font. Each character and white-space character takes up only as much space as the actual width of the glyphs. A 'W' is much wider than a '.' All you have to do is change the font of the TextBox or RichTextBox to a fixed-width font.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you so much.
Nina
|
|
|
|
|
Dave, could you email me pls ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sure. I'll be home in an hour. It's a 50 mile drive to work... YUK!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|