|
First off, let me just say that this question is just for information purposes. (I'm kinda curious as to why this is happening)
I have a wierd error with the VB program I have access to here.
The error is in the code and has to do with some of the standard tabControl methods.
What happens is that if that there is a method that returns an in depending on what letter is put into it. The returned int is then used to select which tab page is shown by the control.
To get the code to work it goes something like this:
Dim index As New Integer
tabIndex = Groups.ConvertToNumber(Attribute.Group)
If Not Groups.ConvertToNumber(Attribute.Group) = -1 Then
FunctionPicker.SelectedTab = FunctionPicker.TabPages(tabIndex)
End If
The above code works. However if I change the code to this:
If Not Groups.ConvertToNumber(Attribute.Group) = -1 Then
FunctionPicker.SelectedTab = FunctionPicker.TabPages(Groups.ConvertToNumber(Attribute.Group))
End If
It no longer works, when it should. (And as far as I know worked in previous versions)
Any idea as to why this happens?
- Munty
|
|
|
|
|
Disregard previous reply if you saw it... Eyes playing tricks on me.
Don't know.
But here's my 2 cents.
We don't really know what ".ConvertToNumber" returns. We're assuming it's a user-written function and returns something numeric, but...
But the whole thing becomes moot if the code is written properly.
Suggestion: To make the code more efficient, don't execute the expensive function more than once if you can help it.
Execute it, get the validated results in tabIndex, (preferably within a Try block, using System.Convert), so you know exactly what you're dealing with, and then just use the index.
Dave
|
|
|
|
|
Hi there.
The ConvertToNumber always returns a number. The number returned will always be from between -1 and 7. (-1 being the Error number)
I've been stepping through the program with Visual Studios debugger, So I can tell ya that it is definately returning a number. For the testing I was doing, it always returned the number 2. However if I looked at the FunctionPicker.SelectedTab it always states that it contains nothing.
But it always works correctly if I put it into an pass the results of ConvertToNumber into an integer before passing it into the TabPages method.
Hence why I'm calling it a wierd bug
- Munty
|
|
|
|
|
That is definitely a puzzler. If I get some time later tonight I will set one up and see if I can reproduce it.
Dave
|
|
|
|
|
Munty -
Couldn't reproduce it.
I set up a form with a tab control with 8 pages, various overloaded functions to return integers and singles (which I then cast to Int) etc, buttons to set the preconditions and call each scenario, ...
Got the right tab selected every time.
You're right. That's a weird bug.
|
|
|
|
|
I am doing a page for user to editing the information. Before the user click a "SAVE" button, I need to check the time stamp from the database to check whether there is person editing the information before the user. If yes, then I need to pop up a window to show the difference the information.
Please kindly assist.
Thanks
|
|
|
|
|
create a form for the pop up window (frmPopUp)
put the controls that u need in it (labels, textboxes, images,...)
Then
<br />
dim objPopUp as new frmPopUp<br />
objPopUp.(what u need to initialize ...) = ...<br />
objpopUp.show/showdialog 'Depending on how u want it to act (modal,modaless)<br />
hope this would help
Best Regards
3ala2
|
|
|
|
|
I don't have a method of objpopUp.show. May be it is due to I am creating a web form. I still cannot pop up a new window.... But anyway, thanks for 3ala2.
Pls kindly help.
Many Many Thanks
|
|
|
|
|
u should have posted this in the ASP.net section. I gave u windows application code
for pop ups in web u need to use window.open javascript function
Best Regards
3ala2
|
|
|
|
|
|
No problem ...
Best Regards
3ala2
|
|
|
|
|
|
how to search a file in hdd.mean i want to code if this(abcd.txt) file found then form1 should show other wise form2 should show
|
|
|
|
|
It's not peppy code if you need to look at the entire harddrive but this will get you through it if you know where to start.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If bFindFile("C:\", "abcd.txt") Then
MsgBox("Yep") 'show form1
Else
MsgBox("Nope") 'show form2
End If
End Sub
Private Function bFindFile(ByVal sStartFolder As String, ByVal sFileName As String) As Boolean
Dim bFound As Boolean = False
GetDirectories(sStartFolder, sFileName, bFound)
Return bFound
End Function
Private Sub GetDirectories(ByVal sPath As String, ByVal sFileName As String, ByRef bFound As Boolean)
For Each sDir As String In Directory.GetDirectories(sPath)
bFound = bCheckFiles(sDir, sFileName)
If bFound Then Exit Sub 'we found it...get out of the loop
GetDirectories(sDir, sFileName, bfound)
If bFound Then Exit Sub 'we found it...get out of the loop
Next
End Sub
Private Function bCheckFiles(ByVal sPath As String, ByVal sFileName As String) As Boolean
Dim saFiles() As String = Directory.GetFiles(sPath)
sFileName = sFileName.ToLower
For Each sFile As String In saFiles
If Mid(sFile, InStrRev(sFile, "\") + 1).ToLower = sFileName Then Return True
Next
System.Windows.Forms.Application.DoEvents() 'so your PC does not lock up looking for the file
Return False
End Function
|
|
|
|
|
|
Hi Friends
Anybody please tell me how to compile the InstallShield Project from a commandline.
I am using InstallShield12 for the Creation of the Project.
I used IsCmdBld.exe,But i got only the .msi file.No other files(Merge Modules,Other Dll's) are there.Can anybody plz....help me to solve this problem.
Thanks In Advance,
Jeeva
|
|
|
|
|
What's wrong with the .MSI file? Aren't you able to install your app using that?
Chandra
|
|
|
|
|
Hi Chandra
When I am trying to install that msi,i got an error saying that
'The installer has encountered an unexpected error installing this package.This may indicate a problem with this package.The error code is 2714'
I think it doen't include any merge modules.But i don't know how to specify it,Can u plz.. help me
Jeeva
|
|
|
|
|
hi everybody
in my project i have to save the contents of a datagrid to excel file and word file. ie. i have to save the file in .xls and .doc extension . what should i do . any help will be appreciated thanks i advance
sebastian
|
|
|
|
|
when ever you set your dataGrid's datasource from the ds that time pic the ds.Tables Schema and write in Excel file with making the same schema in excel file and write in excel's files schema or fields.
Try it
Note: this is Logically solution.
Pavan Pareta
|
|
|
|
|
how to convert html file in doc file with same format.
Hi all,
i have Developed a ASP.net programm. and i have to convert html file in (.doc/.rtf) file formate, with a same formate of HTML file. using ASP.net Coding User can edit a word file on the web as html formate and he will save this file should be same formatting in MS-Word or RTF file formate.
Pavan Pareta
|
|
|
|
|
Hello,
I have to insert a current date and current time into a database.
I am using vb 2005 and sql 2005.
Dim time As DateTime<br />
Dim day As DateTime<br />
<br />
time = Date.Now.ToShortTimeString()<br />
day = Date.Now.ToShortDateString()
I am using the above to get the time and the day. I would like to display the date as 1/11/2006 and the time as 10:08.
However, in the database it is showing as:
Date: 10/31/2006 12:00:00 AM
Time: 10/31/2006 9:34:11 PM
I have set the database field to nvarchar(50). I can't have the fields as dateTime, as I don't want to display a pop calandar in my ultragrid.
Is there a problem with the code?
Thanks in advance,
Steve
|
|
|
|
|
Use Like this:
Declaration
Dim time As DateTime
Dim day As DateTime
Private culture As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("hi-IN")
--------------------
time = Date.Now.ToShortTimeString()
day = Date.Now.ToShortDateString()
Dim temp As String = Convert.ToDateTime(time, culture)
Dim var As String = Convert.ToDateTime(day, culture)
This will convert the date and time into Indian culture.
temp will have the value of 9:30:00 AM
and
var will have the value of 11/1/2006
Hope u will got it.
Janani
|
|
|
|
|
steve_rm wrote: I can't have the fields as dateTime, as I don't want to display a pop calandar in my ultragrid.
Don't let limitations like that mess up your database design. Store the datetime properly in the database, and convert it to strings when you are fetching data to be used with that component.
steve_rm wrote: Is there a problem with the code?
You have been "helped" by VB to convert the values back to DateTime. The extra conversions that are added, as you are storing the values in DateTime variables, are equivalent to:
time = Convert.ToDateTime(Date.Now.ToShortTimeString())
day = Convert.ToDateTime(Date.Now.ToShortDateString())
A DateTime structure always has a date and a time, and no information about formatting. If you convert a string containing only a date to a DateTime, it will get the time 0:00. If you convert a string containing only a time, it will get the current date.
---
b { font-weight: normal; }
|
|
|
|
|
Hi all,
I have a problem where based on one of the column's value in the datagrid the next column should allow the user to enter the value.We have some calculations to perform if the first coulmn's value is "True".But if its "False" i want user to enter some amount or just leave it as blank.
If cbocalculate ="Yes" then
result=.....
else
here i want the column to be changed into a textbox so that user can enter
values..Have been trying but no success YET,Please can anyone help?
Thanks,
Durga
Durga
|
|
|
|