|
Thanks, that helps. I still don't understand why a region that is not invalidated would flicker, but ....
|
|
|
|
|
I have to read from a text file, but I can't get all of the fields out. As you can probably see, there is no real delimiter. Someone please help me.
1 ANSARI, EHSAN B 111-11-111 BT SR CSCI P Enrolled
2 CRAWFORD, BRIAN KEITH 111-11-111 BT SR CSCI P Enrolled
3 ELLIS, RICHARD M 111-11-111 BT SR CSCI P Enrolled
4 GARDNER, JAMES ROBY 111-11-111 BT SR CSCI P Enrolled
5 GNAU, DANIEL C 111-11-111 BT SR CSCI A Enrolled
7 GOULDER, JEFFREY SCOTT 111-11-111 BT SR CSCI P Enrolled
8 LAWSON, BRANDI NICOLE 111-11-111 BT SR CSCI P Enrolled
9 MONROE, JENNIFER M 111-11-111 BT SR CSCI P Enrolled
10 MOORE, MELISSA ANN 111-11-111 BT SR CSCI P Enrolled
11 OVERHOLT, JAMES PATRIC 111-11-111 BT SR CSCI P Enrolled
12 PARKER, BRIAN DOUGLAS 111-11-111 BT SR CSCI P Enrolled
I've got some code and it loops through all rows, but how can I get all of the "columns" extracted?
Here's my code:
Public Sub LoadStudents(ByVal strFile As String)
Dim fs As New FileStream(strFile, FileMode.Open)
Dim sr As StreamReader
Try
sr = New StreamReader(fs)
Dim str As String
Dim ar As String()
Do While sr.Peek <> -1
str = sr.ReadLine
If str.Trim.Length <> 0 Then
ar = str.Split(CChar(" "))
stud = New Student
With stud
.Number = CType(ar(0), Integer)
'.Last = CType(ar(1), String).Substring(0, .Last.Length - 1)
'Fix above parsing error
.Last = CType(ar(1), String)
.First = CType(ar(2), String)
.MidI = CType(ar(3), String)
.ID = CType(ar(4), String)
.College = CType(ar(5), String)
.Classification = CType(ar(6), String)
.Email = CType(ar(7), String)
.Major = CType(ar(8), String)
.Paid = CType(ar(9), String)
.Enrolled = CType(ar(10), String)
End With
End If
Loop
Catch ex As Exception
Exception(ex)
Finally
fs.Close()
sr.Close()
End Try
End Sub
|
|
|
|
|
Sorry for the error in my description due to copying and pasting the contents of the text file.
Some spacing are as follows:
1. Glavin, Tom 111-11-1111 BT SR CSCI P Enrolled
2. Justice, David 111-11-1111 BT SR CSCI P Enrolled
|
|
|
|
|
Looking at the data it seems that a space character separates the various columns of data. The exception though is that the first name can contain more than one name (i.e. the student's middle names as well). That's the trick to parsing this data.
The code you have should work with the addition of detecting the number of first and middle names. To that end I'd inspect the value of UBound(ar). For a person with no middle name the UBound should be = 9, with one middle name = 10, with two middle names = 11 and so on.
You could use this information to set a variable as the index to the ar() string array and automatically capture the data columns viz:
With stud
.Number = CType(ar(0), Integer)
'.Last = CType(ar(1), String).Substring(0, .Last.Length - 1)
'Fix above parsing error
.Last = CType(ar(1), String)
.First = CType(ar(2), String)
' Determine the index of the middle name if it exists.
' This logic will need to be changed slightly if multiple
' middle names are expected in the data.
Dim n As Integer
n = UBound(ar) - 9
If n = 0 Then
.MidI = vbNullString ' or "" depending on your requirments
Else
.MidI = CType(ar(3), String)
End If
.ID = CType(ar(n + 3), String)
.College = CType(ar(n + 4), String)
.Classification = CType(ar(n + 5), String)
.Email = CType(ar(n + 6), String)
.Major = CType(ar(n + 7), String)
.Paid = CType(ar(n + 8), String)
.Enrolled = CType(ar(n + 9), String)
End With
There are several assumptions in the above code, but you should get the idea how it works.
...Steve
|
|
|
|
|
There are only last, first, and middle initial. The even spacing was a typo. I pasted directly from the text file but the spacing didn't stay for some reason. Please look at my reply to the post using the actual spacing issues I encountered.
Thanks for your reply!
|
|
|
|
|
My code will still work since it does not matter how many spaces tere are between the data columns and also the middle initial/name does not exists for some entries but does for others.
...Steve
|
|
|
|
|
hi.
advanced programmer, but new to vb.net.
can anyone recommend a control or know which one microsoft word uses for it's document window?
same one as in vb.net's code editor window.
eg. you type incorrect spelling in this control and it underlines errors, colors your text, adds spaces for your code, etc.
like some really advanced textbox control, what is it?
cheers all and look forward to all your suggestions
--Graham
|
|
|
|
|
HeroRaven wrote: can anyone recommend a control or know which one microsoft word uses for it's document window?
Word uses its own proprietary control for its "text editor"
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
You could try the one that comes with QueryCommander. It looks very similar to the VS.NET IDE. Might do something that Word can, but I have not messed with it much. http://sourceforge.net/projects/querycommander
The network is down...let's go get bagels.
|
|
|
|
|
do you really believe MS Word were programmed with VB.NET ?????
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
it's not one control. you can try to implement all the things by yourself. for example, for spell check, there is aspell, etc...
|
|
|
|
|
yeah i know that but for changing text in the textbox in realtime, putting color underlines, etc.
and yeah microsoft announced a few years back ms word was programmed in vb. so i'm pretty sure the new versions were too.
|
|
|
|
|
I have a program that handles my DVD collection. It is a VB.net front-end with an Access dB. I am trying to load a picture (dvd covers) into the dB. I want to be able to save a bitmap or jpeg for each record. I have the load option down but my program won't save into the database. I click the save button and nothing happens. The save option has worked fine until I added this section of code.
In the dB, the picture column is a OLE Object and when I did my dB connection in VB.net, the schema showed that the picture column was a base64binary. After running some test, it seems one line of code is causing this problem but I don't know what to put there. It is in the data binding code where I have "picDVD.DataBindings.Add("long", dsDVD, "DVD.Cover Pic")". The quotations around long is what I don't know what to use. I am uncertain of what datatype of for base64binary.
Does any of this make sense? If so, any advice would be greatly appreciated! Thank you.
Jason
I'd rather have a bottle in front of me than a frontal lobotomy.
|
|
|
|
|
|
I am new to VB.net but have a need to send secure data from my web site to another web site and then they will return data to me. What is the best way to handle this ?
Thanks
|
|
|
|
|
You could start with the HttpWebRequest and HttpWebResponse classes in System.Net; these allow you to interact directly with a site via HTTP.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
|
in VB how can we can get the code of the .exe file generated if we loose the source file??
|
|
|
|
|
|
Can someone help me how can I set my transparent form so I can click through it. if there is an icon behind my form (on Desktop for example), and I click, so the icon clicked....
OmarMallat
|
|
|
|
|
If it got it right, you have to do this:
public const int HTTRANSPARENT = -1;
public const int WM_NCHITTEST = 0x84;
protected override void WndProc(ref Message m){
if (m.Msg == WM_NCHITTEST){
m.Result = new IntPtr(HTTRANSPARENT );
}
else {
base.WndProc(m);
}
} I do something like this in a sort of custom ToolTip class.
EDIT: kut wrong forum
Public Const WM_NCHITTEST As Integer = 132
Public Const HTTRANSPARENT As Integer = -1
Protected Overrides Sub WndProc(ByRef m as Message)
If (m.Msg = WM_NCHITTEST)
m.Result = New IntPtr(HTTRANSPARENT )
Else
MyBase.WndProc(m)
End If
End Sub
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
-- modified at 16:51 Saturday 29th October, 2005
|
|
|
|
|
Thanks, but I need a VB.NET Code.. if it's possible.
OmarMallat
|
|
|
|
|
Just modified it
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Sorry, but I'm too poor in C++ or C#.
OmarMallat
|
|
|
|
|
I already edited my first post...
Seems to me you missed it.
[Marc] wrote:
EDIT: kut wrong forum
Public Const WM_NCHITTEST As Integer = 132
Public Const HTTRANSPARENT As Integer = -1
Protected Overrides Sub WndProc(ByRef m as Message)
If (m.Msg = WM_NCHITTEST)
m.Result = New IntPtr(HTTRANSPARENT )
Else
MyBase.WndProc(m)
End If
End Sub
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
-- modified at 17:03 Saturday 29th October, 2005
|
|
|
|