|
Hello,
I need export big texts of the my DataBase to MS Word, I using field of the DataBase in "Text" Format.
This is code I using:
==========================================================================
Dim varDR_DataReader As OleDbDataReader
objWord = CreateObject("Word.Application")
objWord.Documents.Open(Directory.GetCurrentDirectory & "\NewDoc.doc")
ReplaceVariable("@Book", varDR_DataReader ("Field_Book"))
ReplaceVariable("@Page", varDR_DataReader ("Field_Page"))
ReplaceVariable("@Description", varDR_DataReader ("Field_Description"))
objWord.visible = True
varDr_DataReader.Closed
Private Sub ReplaceVariable(ByVal Achar As String, ByVal Repl As String)
With objWord.Selection.Find
.Text = Achar.ToString
.Replacement.Text = Repl.ToString
.Forward = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
While .Execute = True
objWord.Selection.Select()
System.Windows.Forms.Clipboard.SetDataObject(Substituir)
objWord.Selection.Paste()
End While
End With
End Sub
===========================================================================
But, Field_Description it's very big, and caused overflow in ReplaceVariable.
Help me, please...
Thank's
Plinio
-- modified at 13:11 Friday 3rd November, 2006
|
|
|
|
|
hi, ive been trying to edit the global.aspx file to create an application connection to the SQL Server.
Code
<%@ Application Language="VB" %>
<%@ Import Namespace="System.Data.SQLCLIENT" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Dim sqlConn As New SqlClient.SqlConnection
Dim sqlCommand As New SqlClient.SqlCommand
Dim ConectStr As String = "Data Source=DEVELOPMENT\SQLEXPRESS;Initial Catalog=Testdata;Integrated Security=True"
sqlConn = New SqlClient.SqlConnection("ConectStr")
sqlConn.Open()
Application("SQLConnection") = sqlConn
End Sub
Any ideas where im going wrong as this keeps failing.
Thanks in advance
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
You've got multiple problems with this.
First, ApplicationStart only executes the first time a page request is made to your site. It will never execute again.
Second, since this only executes once, anything this code does will never get executed for any subsequent page requests. Since web applications are stateless, your page code has to be written so that each page requests builds and destroys the objects it needs on EVERY request, not just the first one.
Any object you create in ApplicationStart will fall out of scope and not be usable anywhere in your page's code. So, building an SQL connection in ApplicationStart will not do you any good since they will no longer exist after ApplicationStart is done executing.
Lastly, you REALLY have to be specific in your posts as to what the code is supposed to be doing and supply any and all error messages you get along with the lines of code that the errors occur on. Without that, all you've done is pulled your car into the dealership and told the service guy "It's broke." How's he supposed to know what you're talking about?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I'd like to know how i can add all the file names of pictures in a directory to a listbox, and adding their extension in a column at the right of the file names. Anyone knows how to do this? (Sample code pls? )
--Zaegra--
|
|
|
|
|
Dim files() As String = IO.Directory.GetFiles(PathToDirectory)
|
|
|
|
|
I used a listview. I don't like the multi column behavior of a listbox. If you want to go through sub directories as well there is more to it obviously
1) Setup a listview
2) make sure you change it's 'view property to 'detail'
3) edit columns. add 2 call and them "File Name" and "Extension"
4) include the code below to populate it.
Imports System.IO
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oItem As ListViewItem
For Each sFile As String In Directory.GetFiles("c:\picturePath")
oItem = New ListViewItem(Mid(sFile, InStrRev(sFile, "\") + 1).ToLower)
oItem.SubItems.Add(Mid(sFile, InStrRev(sFile, ".") + 1))
Me.ListView1.Items.Add(oItem)
oItem = Nothing
Next
End Sub
End Class
|
|
|
|
|
Thanx, but is there a way to only display image file names in the list? The code you gave me adds all files in a dir
--Zaegra--
|
|
|
|
|
sure you just need to apply a filter
Imports System.IO
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oItem As ListViewItem,sExt as string
For Each sFile As String In Directory.GetFiles("c:\picturePath")
sExt = Mid(sFile, InStrRev(sFile, ".") + 1).tolower()
Select case sExt
case "bmp","gif","tif","jpg","jpeg" 'etc.
oItem = New ListViewItem(Mid(sFile, InStrRev(sFile, "\") + 1).ToLower)
oItem.SubItems.Add(sExt)
Me.ListView1.Items.Add(oItem)
oItem = Nothing
case else
'ignore file
end select
Next
End Sub
End Class
|
|
|
|
|
I have a function that should format a alpha numeric partnumber but it doesnt always work. not sure what i am missing here.
I have the partnumber defined as LONG , which only works on numeric part numbers. However, when I change it to a STRING the function throws an error "Unable to cast object of type 'System.String' to type 'System.IFormatProvider'.". Any advice would be greatly appreciated.
sample data that would be passed into the function follows
partnumber = 1243bu format= ##-###
Code:
Public Function FormatPartNumber(ByVal formatstyle As String, ByVal partnumber As String) As String
'FormatPartNumber = String.Format(formatstyle, partnumber)
Return partnumber.ToString(formatstyle)
End Function
jds1207
|
|
|
|
|
Imports System.IO
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MsgBox(FormatPartNumber("00-000", "3aA33A"))
End
End Sub
Public Function FormatPartNumber(ByVal formatstyle As String, ByVal partnumber As String) As String
If IsNumeric(partnumber) Then Return CLng(partnumber).ToString(formatstyle)
If partnumber.Length < formatstyle.Length Then partnumber.PadLeft(formatstyle.Length, "0")
Dim sFormatted As String = String.Empty
Dim iFPos As Int16 = formatstyle.Length, iPPos As Int16 = partnumber.Length
Do While iFPos > 0
If Mid(formatstyle, iFPos, 1) = "0" Then
sFormatted = Mid(partnumber, iPPos, 1) & sFormatted
iPPos -= 1
iFPos -= 1
ElseIf Mid(formatstyle, iFPos, 1) = "-" Then
sFormatted = "-" & sFormatted
iFPos -= 1
End If
Loop
If iPPos > 0 Then
Do While iPPos > 0
sFormatted = Mid(partnumber, iPPos, 1) & sFormatted
iPPos -= 1
Loop
End If
Return sFormatted
End Function
End Class
|
|
|
|
|
Getting the following error: Conversion from string "0022BU" to type 'Long' is not valid.
Any suggestions!
|
|
|
|
|
did you use my code as is? the 2nd argument is type 'string'.
this line should of caught that
If IsNumeric(partnumber) Then Return CLng(partnumber).ToString(formatstyle)
if it's not numeric then it will positionally replace the format with the value.
|
|
|
|
|
Yes, I did use your code as is and I am still getting the same error.
|
|
|
|
|
i don't know what to tell you. i plugged in your value and got 002-2BU like I expected. try catch it then.
try
Return CLng(partnumber).ToString(formatstyle)
catch
end try
'if it is numeric then it will return formatted
'else it falls below to the rest of the code
|
|
|
|
|
Hi, guys. I need to know how to create a users and programmers manual for a vb.net proyect. Is there any software to help me or do I have to do it all??
Please help, ´cause I´m new in this.
Thank you very much for your time an effort.
Rafael Aguilar Sol
|
|
|
|
|
That depends on the type of project you're talking about and which version of VB.NET you're using.
If you're talking about a control, library, or web server project, then you would comment your code appropriately. But, how you do this depends on the version of VB.NET you're using. For 2002 and 2003, there is no built in support for generating XML Documentation at compile time, so you have to use a 3rd party tool, like VBCommentor (Google it!), and follow it's documentation on how you have to format your comments in your code.
For 2005, there is built in support for this. All you have to do follow the documentation here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok. Thank you, Dave. I´m using the 2003 version so I´ll look for the VBCommentor.
Thanks a lot and God bless.
Rafael Aguilar Sol
|
|
|
|
|
I am working on large-scale project entitled as MIS (Marketing information System). As I told you that I am using Vb 6 as front end, Ms Access as back end and Crystal report 8 as reporting tool.
1) In the project it is required to save dealer’s photo, and it should be shown in individual dealer’s detail report, which will include his/her image. I had taken Common dialog box control to select image and display it in image control.
2) The size of database is very large then, which will be useful from the following?
i. to store image to database?
(But it makes database larger in size which leads to slower access)
ii. Saving path of image in database
To keep database safe I want to try the second option first. Instead coding directly into project, I want test the logic into small program first. As we know that by use of common dialog control we can select image and show it in image control. Also same path can be stored in database. Also we can retrieve the path from database and show it image control.
Until here all things are ok. Now problem is that how to show the image in crystal report. Usually we pass the fields directly to crystal report by sending sql-query to it.
If you require more details, please let me know. I will make it available.
Regards,
Kiran.
-- modified at 1:42 Saturday 4th November, 2006
Kiran Sajanikar
Software Engineer
CleverBIT softwares.
Pune.
|
|
|
|
|
How can i swap two values in database which are retrived in a combobox. Means in selectitem index i m using a event. But I have no idea how should I code for that event.
|
|
|
|
|
Pl. explain by an example
cheers,
Akhilesh Yadav
|
|
|
|
|
|
Hello,
I have this code below but i want to specify it in 24hr format.
time = ScheduledTime.ToString("hh:mm")
I have my sql server 2005 database set for nvarchar but the actual input that is always entered as a date along with the time. e.g. 2/11/2006 10:34
I would just like to have the time specified.
Thanks,
Steve
-- modified at 4:34 Friday 3rd November, 2006
|
|
|
|
|
Try using captial HH for example
time = format(ScheduleTime, "HH:mm")
this should provide the time in 24 hour system where as
time = format(ScheduleTime, "hh:mm")
will provide the time in the 12 hour system
Steve Jowett
|
|
|
|
|
Thanks,
Thanks worked great.
|
|
|
|
|
I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.
|
|
|
|