|
Ok I have it searching the file fine, it reads the line and prints it out how it is supposed to. But now I guess is how to work on my second question. I can split the line fine, the only problem is I'm unsure of how to get the last number in the string or the last thing that has been split. Say we have :
[2449] = "0:37;5277;1201.7;1297.2;1436.9;467.4",
I need to get the last number in the string that is after the last ";" so it would be "467.4". I'm guessing I would need some type of loop but I'm not sure how to count the number of splits it has done. The number I'm looking for will always be after the 5th ";". If I can get that number, the only thing left to do would be to format it. But that can be saved for later.
|
|
|
|
|
Never mind this, I actually figured it out on my own. My last step is to round the last number and format it. I think this would of a different topic from my original question. I have this code and I need to round the number in the array of a string which I don't know if it is possible.
Dim aryTextFile() As String
This is the item I need to round, but it is in array form I believe, and needs to be converted to a decimal to be rounded. I'm not sure how this would be done. I tried making an integer and then assigning the array item to the integer and rounding from there before putting it in the label but this did not work.
What this code does is:
1. Opens the file
2. Reads it line by line till it gets to "[2449] = ""0:"
3. Reads the line that is after "[2449] = ""0:" to get "[2449] = "0:37;5277;1201.7;1297.2;1436.9;467.4","
4. After it gets that string it splits it up 6 times.
5. After the 6th split it gets this string 467.4",
6. It trim the ", off and leaves me with 467.4
7. After 467.4 I need it to be rounded to 467
8. After it is rounded to 467 I need it to be formatted into a certain in game currency. The format goes 100 copper = 1 silver, 100 silver = 1 gold. The number above would be formatted as 4s 67c so its somewhat reversed. Maybe this can be done with simple math.
So far I only need steps 7 and 8
I also want to know if it is in anyway possible to put this code into a function and have data input and returned from it. The information that is in there is hard coded and I don't want to do this for every instance as it would get confusing. I only have it hard coded to test it.
Dim fs As New FileStream("C:\Program Files\World of Warcraft\WTF\Account\<account name="">\SavedVariables\Auc-Stat-Simple.lua", FileMode.Open)
Dim sr As New StreamReader(fs)
Dim intcounter As Integer
Dim line As String = ""
Dim count As Integer
Dim LineOfText As String
Dim i As Integer
Dim aryTextFile() As String
Dim startval As String
Dim chArr() As Char = {"""", ","}
startval = "[2449] = ""0:"
Try
Do
line = sr.ReadLine()
If line IsNot Nothing Then
If line.Contains(startval) Then
intcounter = intcounter + 1
If intcounter = 1 Then
LineOfText = line
aryTextFile = LineOfText.Split(";".ToCharArray)
For i = 0 To UBound(aryTextFile)
count = count + 1
If count = 6 Then
Label11.Text = (aryTextFile(i).Trim(chArr))
count = 0
End If
Next i
'Label11.Text = line
End If
End If
End If
Loop While line IsNot Nothing
Catch a As Exception
Label11.Text = "Not Found"
End Try
sr.Close()</account>
|
|
|
|
|
Ok again with a little tweaking I got that working. So now my main concern is being able to put all this code into a function.
|
|
|
|
|
I wondered if anyone may know, I just want to write a bit of VBA to put in an excel macro so that it a sheet of data, wherever a row contains a 0 in a certain column (e.g. column e), the row will be deleted.
I know it would be a loop but I have never been very good on loops.
So basically, e.g. it would do this
Row(2)- if cell E(2) = 0 delete row, search next row, search until rows are null
thanks
|
|
|
|
|
This [^] site is a good resource for VBA.
I had typed out a detailed response to your query, but lost it when I hit the "Post" button I hope you can find your solution from the site I have pointed you to.
|
|
|
|
|
How to add an icon of my program to Internet Explorer Toolbar and accessing my program from there?
Gagan
|
|
|
|
|
Do you mean the icons on the top bar containing the favorites icon, history icon...etc?
Or do you mean a new toolbar like google toolbar kind of thing?
|
|
|
|
|
Thanx for expressing your interest in my question.
I wan to add my program on IE Toolbar like Google or any other toolbar so that I can access my program from there...
Plzzzzz reply......
|
|
|
|
|
All I know about this is that somewhere in the group policy or somewhere like that there is a option to put custom toolbars there, but I think that only applies to IE6 and the way it works it dosent look like it could be easly done with an application.
Lloyd J. Atkinson
"Logic will get you from A to B, but imagination will take you everywhere" - ALbert Einstein
I look at Microsoft, and turn to my poster on the wall saying: "Bang head here in case of stress".
|
|
|
|
|
Thanks Lloyd Atkinson but I want to put my program on IE Toolbar using vb.net codes not by using gpedit policy.
If you got the solution then reply me.
Thanx.
|
|
|
|
|
How to open a text file in a text editor in my application in VB.NET by using 'open with' option.For ex- when I open an image in MS Paint by using 'open with' option, the image is opened directly in Paint for editing. The same thing I want to do with my program.
Plz help me to open a file in VB.NET by using 'open with' option.....
|
|
|
|
|
|
Could you explain it for me?
Plz reply me...
|
|
|
|
|
The filename is passed as an argument to your program. Just get the arguments, and you'll have the filename. Then you can open the file or whatever else.
|
|
|
|
|
Shell("notepad.exe c:\Your File.txt", AppWinStyle.NormalFocus)
Does that help?
Normally you would have to specify the full path and file name of the application to open, but because in this case notepad is in the windows folder, you can just use "notepad" and the path in the code above is the file to open
Lloyd J. Atkinson
"Logic will get you from A to B, but imagination will take you everywhere" - ALbert Einstein
I look at Microsoft, and turn to my poster on the wall saying: "Bang head here in case of stress".
|
|
|
|
|
Thanks Lloyd Atkinson for your suggestion but it is not a proper answer for me.
I want to open a text file by right clicking on it,choosing 'open with' option,and selecting my program.
I want to open text file as 'open with' my program instead of executing my program and then opening texe file.
Plz help me...
|
|
|
|
|
Hi Friends,
In these days i am in a problem because i have to store MS Word file into SQL Database's Table and i am using VB.NET 2005. So anybody here who can help me.
Thanx
Naresh Rajput
|
|
|
|
|
There are a lot of examples out there. Here[^] is one such example. A search will return a lot more.
|
|
|
|
|
Hi
Thanx for reply but dear it saves Image into sql instead of MS Word file
Thanx
|
|
|
|
|
There's no difference between the two. Either way, the file is just a stream of binary data. The technique is identical.
|
|
|
|
|
This sounds simple but I am unable to get it to work.
The function is passed a dataset, SQL Connection String and a table name. It is supposed to replace the contents of the table with the dataset. Why does this not work?
Public Function UpdateSQLTable(ByVal myConnection As String, ByVal mySelectQuery As String, ByVal myTableName As String, ByVal myDataSet As DataSet) As DataSet
Dim myConn As New SqlConnection(myConnection)
Dim myDataAdapter As New SqlDataAdapter
myDataAdapter.SelectCommand = New SqlCommand(mySelectQuery, myConn)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapter)
myConn.Open()
Dim ds As DataSet = New DataSet
Dim myRecordCount As Integer = myDataAdapter.Fill(ds, myTableName)
ds.Clear()
ds.Merge(myDataSet)
Try
cb.DataAdapter.Update(ds, myTableName)
Console.Write("Updating DataSet succeeded!")
Catch e As Exception
Console.Write(e.ToString())
Return Nothing
End Try
myConn.Close()
End Function
|
|
|
|
|
Had a look at it and threw the hands in the air - bloody MS wizards why can't you people use stored procedures and understand the sql you are using instead of relying on wizards.
Probably because you use merge on the data set and it confuses the wizard (someone at MS probably didn't think it would be useful)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
ok, then if i do loaddatarow then would it work
|
|
|
|
|
As I said, I never use the wizards but why don't you see if it creates the script BEFORE you merge the datasets (not on the empty one - the original myDataSet).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Standard Question #1: What's the message, exactly?
|
|
|
|