|
There may be an easier way but you can convert the type name to a string and compare using that
eg
Select Case typeof(myobject).ToString
Case GetType(String).ToString
Return "This is a string"
Case GetType(Integer).ToString
Return "This is a number"
Case else
return "Unhandled type: " & typeof(myobject).tostring
End Select
What that is doing is getting the string definition of the 'myobject' and then comparing that to the string values of the types of integer, string, etc
There is probably a better way of doing this but it should work OK.
|
|
|
|
|
Hey all:
I have written a code that will export my data from Datagrids to Excel. It is taking sometime to write the data in excel file. I thought it would be better if I could provide some visual feed back to user like in progress bar or any other when my application writes data in Excel.
Can any body help me how to set the inteval and how can know that excel application is opened from the code?
Others type of suggestions for achieving my tasks is highly appreciated.
|
|
|
|
|
Hi,
Don't know if this will help, But I have used this a few times in excel to show a progress in the status bar...
Sub StatusProgress()
'
' Progress Application Statusbar
'
Dim intIndex As Integer
Dim sngPercent As Single
Dim intMax As Integer
intMax = 100
For intIndex = 1 To intMax
sngPercent = intIndex / intMax
ProgressStyle sngPercent
DoEvents
'------------------------
' Your code would go here
'------------------------
Sleep 100
Next
Application.StatusBar = False
End Sub
Function ProgressStyle(Percent As Single)
' Progress Style
' Application Status bar
' Pulsing
'
Dim strTemp As String
Dim intIndex As Integer
Dim intLen As Integer
intLen = 21
intIndex = Int((Percent * 100) Mod intLen)
strTemp = String(intLen, txtPg7a.Text)
If intIndex > 0 Then
Mid(strTemp, intIndex, 1) = txtPg7p.Text
End If
Application.StatusBar = "Processing " & strTemp
End Function
Cheers,
Stefan.
All answers have a question? All code has an end.
|
|
|
|
|
Opps,
Adjustments to above code...
Replace 'txtPg7a.Text' with "o" and replace 'txtPg7p.Text' with "•"
Sorry..
Cheers,
Stefan.
All answers have a question? All code has an end.
|
|
|
|
|
Hey I repalced whatever you have told me but I still get some compile errror?
What exactly o and . are doing?
and it also gave me some erros on other parts of code. Is the code written in VB.NET?
|
|
|
|
|
Hey,
Sorry forgot to declare 'Sleep'
Place this at the top of your module
Option Explicit<br />
<br />
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long )
The "o" and "." are use to show a progress in the status bar, the "." runs along the "o" to give you the progress.
Hope this helps.
Cheers.
Was written in Visual basic
"All answers have a question? All code has an end."
|
|
|
|
|
Hi,
Is it possible to have multiple thumbs along a slider control, if so can anyone direct me as to where I can find informantion on how to do this..
Thanks in advance!
Stefan.
All answers have a question? All code has an end.
|
|
|
|
|
No, using the standard TrackBar control, it isn't. You'd have to use a 3rd party control that offers this functionality, or write your own version, or use two trackbars coordinated to show a minimum and maximum range.
|
|
|
|
|
Thanks much appreciated!
"All answers have a question? All code has an end."
|
|
|
|
|
HELP!!!
Hate to trouble you all, but I am a student and have been trying to figure out how to understand arrays. My current delima is that I need to create a program which will give the user the ability to input 10 different numbers, list them in a single box, and then report back which number is the highest and which is the lowest after inputting. I intend to use a button to activate the event. I realize this will require an upper bound of 10 (9), but for the life of me I cannot figure out how to create the user input. Any ideas?
Thanks!
Bruce
"Thank you masked man"
|
|
|
|
|
simple algorithm
declare array
dim myarray(1 to 10) as integer
...
for i = 0 to 9
read num from user
add num to listbox
myarray(i+1)=num 'remember indices in VB start at 1. list boxes are zero indexed.
loop
now that they're in an array and visibly in listbox you can start checking them
smallest = myarray(1) 'assume smallest is first one
for i = 2 to 10 'remember this is the array not listbox
if smallest > myarray(i) then 'if number is less that previous num then
smallest = myarray(i) 'assign smallest to number
loop
...bla bla bla
...do the same with the biggest...
-- modified at 22:05 Sunday 1st July, 2007
|
|
|
|
|
You could do it simply by showing a textbox which allows comma seperated values and then validate the input and then call string.split, for example
Dim myString As String = "1,2,3,4,5,6,7,8,9,10" 'Would come from textbox
'Split the string on commas
Dim items() As String = myString.Split(","c)
'Ensure we have the correct amount of values
If items.Length <> 10 Then
Throw New Exception("Incorrect number of values")
End If
'Now do whatever you wanted with these values.
|
|
|
|
|
Hi,
I am in a spot on concern because I am stuck and do not know what to. All my processing happens on one page.
My page has a file upload control, with an upload button. When the upload button is clicked, it loads the file's contents into a dataset. It loops through the column names of the dataset and populates it to a textbox dynamically. Here the values can me altered and mapped to a database field. When I click the Import button, all the textboxes created are all gone. I do not know how to keep the textboxes there once the Import button is clicked because I need the values in the textbox.
Please can some one help me.
Regards
ma se
|
|
|
|
|
I take it you're using a control array of text boxes.
Perhaps they're not missing. Do something like this to show your textboxes
i=1 'set in form load
...button click
load text1(i) 'assuming you've set index to zero of the first textbox
text1(i).top = text1(i - 1).top + text1(i - 1).height 'set new box pos just below previous textbox
text1(i).visible = true 'show it
...
i=i+1'get ready for next click
-- modified at 21:43 Sunday 1st July, 2007
|
|
|
|
|
Please check:
http://www.brendanvogt.com/SD_ImportExport3.jpg
When I click the Perform Import button then it all disappears. The drop down were created dynamically when I did a file upload.
PS: It wasn't textboxes, but drop downs.
ma se
|
|
|
|
|
I Can't be of much help unless I see some code examples.
You're not setting any visible properties to false for the list ctrls are you?
Post the code for the Perform Import event.
|
|
|
|
|
Hi, I am populating a grid from an array which contains a list of records. I have to include a combobox in the grid at runtime and combo should contain different items for each data row in the grid.
But when I create a DataGridViewComboBoxColumn and assign it to the grid, the combo items are same for each row, I have no idea how to create unique combo list to each row. I will appreciate if someone can help me
Thanks
Nas
|
|
|
|
|
dear manish,
you have to add a new combolist everytime.
so in the itemdatabound column make sure the combolist is new or not.
then add the items there. it is very simple to check them.
All The Best
Sathesh Pandian
|
|
|
|
|
Hi Everyone,
I'm writing an application that implements an on-screen keyboard (because the Windows on-screen keyboard is extremely small and hard to use) and I'm having problems setting focus to the desired window in which the user wishes to type.
I'm using a few User32 API calls to get the active window handle number and then set the active window once I know what the handle is. This seems to be working OK. However, the window which has focus (the one receiving the typing) flickers as the user clicks on a key.
This is because as the user touches a key to type, it gives the keyboard focus and then immediately sends focus back to the window in which the user is typing, hence the flickering. So...
Question #1:
How can I eliminate the change of focus and always give focus to the desired window so that there is no flickering back and forth between my keyboard application and the window receiving the typing?
Question #2:
This is not just a standalone keyboard, but is a small part of a larger piece of software. Consequently, there are occasions when the user must use this on-screen keyboard to type into a window within it's parent application or into different forms within the app. One form contains a browser control to a company website. When they keyboard is used to type into any text field on a webpage displayed in the browser control, only every other word is sent to that text box. Two key strokes are required to output one letter. What could be a possible cause of this and how might I go about fixing it?
ANY suggestions or help is much appreciated. Code examples in VB.NET, VB 2005, and C# are fine. C++ OK too but only if it's immediately applicable and can be converted easily to VB.NET.
Thanks in advance to anyone who contributes!!!!
Patrick
|
|
|
|
|
Hi,
I'm using MAPISession and MAPIMessage components to access MS Outlook emails but the "Fetch" does not retrieve any read emails.
The code I have is as follows:
...
MAPISession1.Username = "Outlook"
MAPIMessage1.DownloadMail = True
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.Fetch
iNumOfMsgs = MAPIMEssages1.MsgCount 'iNumOfMsgs declared as a local var
...
iNumOfMsgs returns 0 when there are 100 read emails
Any help with this is very much appreciated
|
|
|
|
|
Hi,
If I have text like:
VariantDisplayMode
How do I break it up so that it displays as:
Variant Display Mode?
Basically it is a seperation at the capital letters.
Regards
ma se
|
|
|
|
|
Use the Regex class with a regular expression pattern like "([a-z])([A-Z])" to find the changes from lower case to upper case. Put a space between them by replacing the occurances using the pattern "$1 $2".
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa, I think that regular expression would fail to properly parse something like "ThisIsATest" because it wouldn't pick up on two capital letters next to one another. I think something like this would be required to find the word boundaries "([A-Z]|[a-z])(?=[A-Z])". Using a replace of "$1 ".
|
|
|
|
|
That's a good point. I didn't think of the special case of single letter words.
---
single minded; short sighted; long gone;
|
|
|
|
|
Another way would be to :
-Create a character Array of your text using ToCharArray()
-Test each character , if Caps add space before the character and add it to the resulting string otherwise add the character to the resulting string:
<code>
Private Function TransFormText(ByVal oText As String) As String
Dim oResult As String = ""
Dim oArray() As Char = oText.ToCharArray()
For Each oItem As Char In oArray
If oItem. = oItem Then
oResult = oResult & " " & oItem
Else
oResult = oResult & oItem
End If
Next
Return Trim(oResult)
End Function
</code>
|
|
|
|