|
|
Dim r As New Random, x As Integer
x = 10 * (r.Next(10) + 1)
chatura
|
|
|
|
|
I have to import a image file(map of a particular area) and then work on it...so as find path for an particular area and route information to a place..so how to proceed with..please help me to get a start and assist me with some codes on this project...also shortest route calculation is embedded on my project using nodes and links...iam new to vb.net so please help me..
|
|
|
|
|
GIS systems tend to work on vector data where the information about the paths are loaded into the system as a series of links and nodes. This information is not present in an image file and would have to be added by the user as current technology is not sufficient for a PC to work this out on its own in a reasonable amount of time.
haripaddu wrote: shortest route calculation is embedded on my project using nodes and links
Search the internet for the "Travelling Salesman Algorithm".
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
This is one that seemed simple at first, but gives me a big headache:
How to get the start- and end-dates of the current week, or last week?
Math has never been my forte anyway. Is there a simple way to do this?
Thanks in advance!
Hiske
|
|
|
|
|
It's easy if you think about it and just look at the documentation for DateTime[^].
To get the date of the beginning of the week, all you need is the current date (Now), what the current day of the week is (Now.DayOfWeek), then just subtract the current day of the week from the current date (Now.AddDays(-Now.DayOfWeek)). To get the last date of the week, just add 6 days to the beginning of the week.
Dim currentDate As Date = Now()
Dim beginDate As Date = currentDate.AddDays(-currentDate.DayOfWeek)
Dim endDate As Date = beginDate.AddDays(6)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave!
Your code sure is al lot shorter than what I had.
This makes for a big improvement...
Hiske
|
|
|
|
|
I am new to programming and wanted to create a little project to learn from. How would I go about saving the source code of a basic HTML webpage to a text file? Any advise links or code would be helpful. I know I am a little over my head right now, but the best way to learn to swim is by jumping in. Thanks.
|
|
|
|
|
You'll have to exaplin this a bit more. Save the HTML from what? A page you're viewing or something you're editing in a TextBox or some other control?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well I just wanted to connect to a page with the program (not view) and then save the source code as a text file so that I can copy some parts of it to a new html file.
|
|
|
|
|
You can get the document text from the WebBrowser controls (I'm assuming your using this!) DocumentText property. All you have to do is open a file and write this string out to it.
Dim sw As New StreamWriter("filepath")
sw.Write(WebBrowser1.DocumentText)
sw.Close()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
A newbie here finally migrating from VB6 to VB 2005.
What is the best way to populate a dataset from a text file? The text file is comma-delimited and doesn't include first line header info.
In VB6, I read the file into a array type declaration (Structure) and then pushed into a db table. I had to take a combination of the fields in the array and combine into single column for the database.
In VB 2005, I would like to take this file and read into a dataset(datatable) and declare my columns plus push mutiple fields into those declared columns. Once in the poper format in a grid or list push to a SQL Server table.
Is this possible? Any help or leads is appreciated. I like what I see thus far in 2005 and excited about migrating.
I am assuming I can use streamreader or such and use a split?
Thanks,
RG
|
|
|
|
|
Hi
I'd first Instantiate a New Datatable, and then use the DataAdapter.FillSchema method. This will give your new table all the column names from the SQL table you are going to update, as well as any constraints like primary keys etc. This will help since you will get an exception if you try to add something to the datatable that is not suitable with your SQL database table.
<br />
Private Sub ImportTextFile()<br />
Dim dt as new DataTable<br />
GetTableSchema(dt, "SELECT * From MyTable")<br />
Dim TextFile() as String<br />
'<br />
'Populate your TextFile() array from the text file<br />
'<br />
<br />
Dim dr As DataRow<br />
For i As Integer = 0 To TextFile.GetUpperBound(0) - 1<br />
dr = dt.NewRow<br />
dr.Item(0) = TextFile(i)<br />
dt.Rows.Add(dr) 'Maybe Put This is a Try...Catch Block<br />
Next<br />
End Sub<br />
<br />
<br />
Public Function GetTableSchema(ByRef dt As DataTable, ByVal SelectString As String) As Boolean<br />
Dim path As String = Application.StartupPath<br />
Dim cnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _<br />
& " Data source= C:\MyDB.mdb"<br />
Dim strSelect As String = SelectString<br />
<br />
Dim cn As New OleDb.OleDbConnection(cnStr)<br />
Dim cmd As New OleDb.OleDbCommand(strSelect, cn)<br />
Dim da As New OleDb.OleDbDataAdapter(cmd)<br />
cmd.CommandTimeout = 5<br />
Try<br />
cn.Open()<br />
da.FillSchema(dt, SchemaType.Source)<br />
Return True<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
Return False<br />
Finally<br />
cn.Close()<br />
End Try<br />
End Function
|
|
|
|
|
How to get the path for font folder ( without try catch statements)
Please help me.
chatura
|
|
|
|
|
My first question would be "Why would you want to?" I've never seen the question asked, ever..., so I'm just woundering what you want to do in that folder.
Imports System.Io
.
.
.
Dim sysFolder As String = Environment.GetFolderPath(SpecialFolder.System)
sysFolder = Path.Combine(sysFolder, "Fonts")
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you Dave
I wanted to copy a font file to that folder
But my fonts folder’s path is , <sysdirve>\WINDOWS\Fonts ,not <sysdirve>\WINDOWS\System32\Fonts, therefore, I modified it like this
Imports system.io
.
.
.
Dim sysFolder As String = Environment.GetFolderPath (Environment.SpecialFolder.System)
sysFolder = Path.Combine(Microsoft.VisualBasic.Left(sysFolder, 11), "Fonts")
Thank you very much again
chatura
-- modified at 2:19 Sunday 5th February, 2006
|
|
|
|
|
Whoops! My bad!
Hmmm...Does the font actually get installed properly if you copy it in like that? Make sure the font works when you're done!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes, that’s true. It didn’t work. To activate it, I had to go to the fonts folder and double click that font file.
Do you (anybody) have any suggestions?
chatura
|
|
|
|
|
You might want to try copying the file into the Fonts folder using the Shell function SHFileOperation . This will cause the SHell to copy the file and possibly install it correctly.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know Shell function, but what is SHFileOperation? How do I use it to copy my font file?
chatura
|
|
|
|
|
The Win32 API Shell functions...SHFileOperation tells the Windows Shell to do the file copy, just like if you were to drag and drop a file in Explorer.
SHFileOperation[^] on PInvoke.net
SHFileOperation[^] on MSDN
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have been searching the internet and reviewing books for a while now trying to determine how exactly to read/write directly to the disk in NTFS using Visual Basic. I have had little success and I am hoping that someone here can help me.
I believe that it comes down to API calls using readfile, etc. to get a handle to the drive and process the information, but I'm at a loss as to how to actually program this.
I've seen a good example in C++ here from T.YogaRamanan but I have not worked in that language for several years and can not break down the logic.
My goal is to write a program that will display the contents of a drive (including deleted files) based on the Master File Table.
Any help would be appreciated but what I am hoping for is someone to clearly identify the steps involved: Step one do this, Step two do that, etc.
Sample Code would be a definite bonus.
Thank You
|
|
|
|
|
Wow, haven't seen this one in a while...
The .NET BCL doesn't have anything that would help you do this. You'll have to P/Invoke all the Win32 API functions to do this. You need CreateFile[^] to open the disk and get a handle. The .NET BCL File functions won't work with disk/volume handles and won't open those either. Once you have the handle, you can only use the Win32 API file functions to read/write the disk.
There's no examples of doing this in VB.NET that I know of. Most of what you'll find is in C++.
The hard part of this is setting up all the calls to CreateFile, ReadFile, WriteFile, and CloseHandle. You'll also need to declare the structures and enums you'll need to call these functions. But, once that's done, it's a matter of calling CreateFile to open the drive, the using ReadFile and WriteFile, to read/write the disk sectors, then CloseHandle to release the disk.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the reply.
Sorry for the confusion, when I referred to Visual Basic, I meant Visual Basic 6, not VB.NET. I never use .net for anything, not yet anyway.
I know it is possible as I've seen demos done in VB but have no accompanying source code.
I have the general idea of what steps are involved but I can not seem to get it working. MSDN only lists the api names but does not provide an example in how to actually use them to achieve anything (except for c++ or c# code).
If anyone has a code sample in Visual Basic 6 of setting up whatever structures, enums and calling the necessary functions, I would appreciate it.
Again, to be clear, I am using Visual Basic 6 on Windows XP with a NTFS formatted drive (obviously) and I am trying to generate a list of all files and folders on the drive (including deleted ones). My main objective here is to access the Master File Table and list all of it's records.
Thanks,
Dan
|
|
|
|
|
IH8Microsoft wrote: I know it is possible as I've seen demos done in VB but have no accompanying source code.
It is possible. I just have never seen any example code for it.
IH8Microsoft wrote: I am trying to generate a list of all files and folders on the drive (including deleted ones). My main objective here is to access the Master File Table and list all of it's records.
This is going to force you to do FAR more than just read disk sectors. Now you're getting into parsing the NTFS structures. You'll want to see if you can find the book "NT File System Internals" (which is out of print BTW). It's the best source of information ever written on NTFS.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|