|
I had high hopes about this since I missed this method last night, but the result is the same. The menu is displaying about half a second prior to the form being loaded.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
modified on Tuesday, October 14, 2008 8:57 PM
|
|
|
|
|
well if all else fails you could use a timer to display the menu a second after the shown event has been triggerd (start the timer in the shown event)
but I'm shure this isn't the best solution, at the moment I can't think of an other way
|
|
|
|
|
I am currently working on a app that loads a TAB delimeted text file
into a listbox then runs through the listbox and breaks each line into
four different listboxes. The file loads fine, but when I try to break
the string appart and add them to different listboxes I get an error.
Here is the code I'm using that is returning the error:
For theList = 0 To lstMain.Items.Count - 1
theListText = lstMain.Items(theList)
Dim Break() As String = theListText.Split(" ")
lstSymbol.Items.Add(Break(0))
lstScience.Items.Add(Break(1))
lstCommon.Items.Add(Break(2))
Next
The error message I get says: 'Index was outside the bounds of the array.'
Does anyone know how I would fix this? Any help would be appreciated.
Jeff
|
|
|
|
|
Dunno. If you still have the initial string var of where your reading the line in, you could split that.
<br />
Example (freehand):<br />
strLine = sr.ReadLine<br />
dim Break() as string = split(strLine, vbtab)<br />
<br />
lstSymbol.Items.add(Break(0))<br />
lstScience.Items.add(Break(1))<br />
lstCommon.Items.add(Break(2))<br />
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Test the length of Break() when adding it to the other listbox, I would guess that there is a missing column in the array.
As kissdznuts said you should be working with the original file instead of the listbox.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I tried the way kissdznuts explained but it only split the first line of the file into their respective listboxes. Also, how do I test the length
of Break()?
Jeff
|
|
|
|
|
Ensure the file is truly tab delimited. When you do the split(strLine, vbtab), you should have sep. elements for each column.
Length test:
break(1).length >= 12 'enter whatever number you're expecting by column.
Hope that helps.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
I don't know what I'm doing wrong.
I tried doing the length test word for word and I get:
1) Expression expected
2) Method arguments must be enclosed in parentheses
For the life of me I just can't get this code to work.
I can't really find anything on the internet about splitting a delimited
file into 'multiple' listboxes. I tried it with the file being TAB
delimeted and comma delimeted and nothing seems to work.
I hate to ask for someone to write the code for me, I don't think I
would learn as much that way. Thanks for everyone's help by the way.
Any more suggestions?
This is my FULL code:
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim stream_reader As New IO.StreamReader("C:\plants.txt")
lstMain.Items.AddRange(Split(stream_reader.ReadToEnd, _
vbCrLf))
lstMain.SelectedIndex = 0
stream_reader.Close()
Catch exc As Exception
' Report all errors.
MsgBox(exc.Message, MsgBoxStyle.Exclamation, "Read " & _
"Error")
End Try
Dim i As Integer
For i = 0 To lstMain.Items.Count - 1
Dim strLine As String = lstMain.Items(i)
Dim Break() As String = Split(strLine, ",")
lstSymbol.Items.Add(Break(0))
lstScience.Items.Add(Break(1))
lstCommon.Items.Add(Break(2))
Next
End Sub
Jeff
|
|
|
|
|
I Have a transparent rtb via:
Public Declare Function SetWindow Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal Index As Integer, ByVal NewVal As Integer) As Integer
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TRANSPARENT = &H20
and, at form_load:
Dim result As Integer = SetWindow(rtb.Handle.ToInt32,GWL_EXSTYLE, WS_EX_TRANSPARENT)
Works fine. The issue I can't seem to figure out is how to display one character over another.
Sample code:
Dim Sym_Font As New Font=
("Symbols",16,font_style.Regular,GraphicsUnit.Pixel)
' "O" is a solid circle
' "F" some symbol to display on top of the circle
rtb.SelectionFont() = Sym_Font
rtb.SelectionColor() = Color.LightGray
' Circle
Dim cp As Integer = rtb.SelectionStart 'get position
rtb.AppendText("O") 'draw the filled circle
rtb.Select(cp, 1) 'back up position
'the overlay
rtb.SelectionColor() = Color.Green
rtb.SelectedText() = "F"
Sym_Font.Dispose()
The "F" displays but the circle is gone. Getting rid of the rtb.select(cp,1) statement will show the circle followed by the symbol.
|
|
|
|
|
Using an unmodified RichTextBox, this isn't supported. AFAIK, you'd have to create your own RichTextBox control, inheriting from the existing one, and supply your own drawing code to do this.
|
|
|
|
|
Thanks. I guess their idea of "rich text" is a little different than mine.
|
|
|
|
|
Hello,
How we can compare two datasets/datatables(without loop) to find out the mismatch of records? I just want find the records which is not in datasetA and which in datasetB?
Thanking you in advance...
Sebastian T Xavier
|
|
|
|
|
AFAIK, you cannot compare two datasets directly.
However, if you load (or merge) the datatable from datasetA to datasetB, you can build a foreign key constraint (or constraints) between the two tables. With that you get an exception if rows don't match.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
yeah, thats a good point... thanks
Sebastian
|
|
|
|
|
You're welcome.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
How are you. Please help me on connecting to access using vb6.0 and to also save the data into access using vb6.0?
|
|
|
|
|
Your question has been answered, thousands of times, over the last 10 years. All it takes is a little searching to find the answers. Here[^].
|
|
|
|
|
Dave Kreskowiak wrote: HereGoogle it[^].
Fixed that for you.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Michelle Shoniwa wrote: using vb6.0
VB6 has been dead and unsupported by Microsoft since March of 2005, you might want to reconsider doing any real work in VB6.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Good day everybody,
I have placed a Timer (System.Threading.Timer) in my app that fires every 1 sec. Every now and then, it just stops runinng. The app does not report any errors, and therefore I have no idea what so ever. Here is the code:
//Assing timer's callback sub
Private Sub FrmMain_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'*Grade Engine
Dim GradeTmrDel As New Threading.TimerCallback(AddressOf GradeTmr_Routine)
GradeTmr = New Threading.Timer(GradeTmrDel, Nothing, 2000, 1000)
End Sub
//this is the callback sub
Private Sub GradeTmr_Routine(ByVal iState As Object)
Static InProcess As Boolean
Dim Msg(), SubMsg(1), NextGrade As String
If InProcess Then Return
InProcess = True
Try
NextGrade = Get_NextGrade()
......
End If
Catch ex As InvalidOperationException
Handle_Er(Err, "GradeTmr") : End
Catch
Handle_Er(Err, "GradeTmr")
Finally
InProcess = False : Grading = False
End Try
End Sub
//Error handler routine - writes to eventlog and posts a message on screen
Private Sub Handle_Er(ByRef Er As ErrObject, ByRef Source As String)
If StatBar.Panels(1).Text = "" Then
StatBar.Panels(0).Text = "Warning! at least one error has been logged!" : StatBar.Panels(1).Icon = New System.Drawing.Icon("W95MBX03.ICO") : StatBar.Panels(1).Text = "Clear"
StatBar.Panels(0).ToolTipText = "Use the Event Viewer to access error's data" : StatBar.Panels(1).ToolTipText = "Click to reset!"
End If
syscorelog.WriteEntry(Er.Description & Chr(10) & Source & Chr(10) & Er.GetException.StackTrace, EventLogEntryType.Error)
End Sub
Thanks for your guidance!
Alex.
|
|
|
|
|
You might want to try stopping the timer at the beginning of the tick handler and starting it again at the end. Comment out the code that keeps track of InProcess.
|
|
|
|
|
Hi Dave,
That is the first approach a tried, but timers within the system.threading namespace
do not have the STOP, START methods of timers within the system.timer namespace.
I then tried using the CHANGE method of this timer to replicate the same behavior, but the app did not like that at all. Apparently what it did was to generate new threads of the timer thus consuming all CPU resources.
I chose the system.threading namespace timer, because I understood this class automatically run the timer in the system provided thread.
The app has two other timers that fire each at different intervals and I have noticed that some times two or all three of them present the same issue.
Hope this helps you to help me
Thanks for your time.
Alex.
|
|
|
|
|
alexvw wrote: That is the first approach a tried, but timers within the system.threading namespace
do not have the STOP, START methods of timers within the system.timer namespace.
Whoops. You're right. So, then destroy the timer and create a new one.
|
|
|
|
|
Hi Dave,
I will try that approach!
thanks.
Alex.
|
|
|
|
|
i m making paint and brush in vb.net, the problem is when i draw any graphic (eg.- line rectanle, e.t.c), on my picture box, the graphic get unsaved on the image, as soon as i do another action i.e- click anwhere else on pic box, minimization of working window...
then drawing done get erased...
now i want u to help me in saving the previously done drawing on the pic box "image"
i m a bigginer, please help me!!!
With regards
Vineet Swami
Isol
Vineet Swami
Isol
|
|
|
|