|
I do the same thing with a label. I first centered it on the form through the format menu, and then I just anchored it on all four sides. The text is centered both vertically and horizontally in the label. As the font size won't change it doesn't matter that the label gets stretched. I don't know however what happens to the image in a picture box, but otherwise it should work the same way.
Johan
|
|
|
|
|
Hi All
I'd like to know how to cancel a print job (using VB) if the user presses the CANCEL button when the print dialog shows. Any ideas?
thanks in advance
|
|
|
|
|
Do anyone know the code to check to see if a row in a file contains any characters such as commas and quotes. For example:
If row("PartNumber").ToString()contains comma or single quote then
'do something
End If
jds1207
|
|
|
|
|
Dim dsTbl As New Data.DataTable("Test")
Dim dsRow As Data.DataRow = Nothing
dsTbl.Columns.Add(New Data.DataColumn("col1", GetType(String)))
dsTbl.Columns.Add(New Data.DataColumn("col2", GetType(String)))
dsTbl.Columns.Add(New Data.DataColumn("col3", GetType(String)))
For i As Int16 = 0 To 10
dsRow = dsTbl.NewRow
dsRow("col1") = Chr(65 + i)
dsRow("col2") = Chr(66 + i) & ","
dsRow("col3") = Chr(67 + i) & "."
dsTbl.Rows.Add(dsRow)
dsRow = Nothing
Next
For i As Int16 = 0 To dsTbl.Columns.Count - 1
For Each dsRow In dsTbl.Rows
If CStr(dsRow(i)).IndexOf(".") > -1 Then
'code for period
ElseIf CStr(dsRow(i)).IndexOf(",") > -1 Then
'code for comma
Else
'code for neither
End If
Next
Next
|
|
|
|
|
This is way more complicated than what I am trying to do. I just want to find the rows that have characters and insert those rows to a database table.
Here is a function I created to insert into table:
Private Sub ErrorLog(ByVal ErrorDescription As String)
Dim myConnString As String = "Data Source=172.16.20.30,1433;Initial Catalog=RAM-PriceBooks;User ID=ProductUpdate;Password=w00ty;"
Dim myInsertQuery As String = "INSERT INTO Error_Log(Error) VALUES ('" & Trim(ErrorDescription) & "')"
Dim myConnection As New SqlConnection(myConnString)
Dim retvalue As Integer
Dim myCommand2 As New SqlCommand(myInsertQuery, myConnection)
myConnection.Open()
retvalue = myCommand2.ExecuteNonQuery()
myConnection.Close()
Here is some code that I am trying to use to find the characters.
If row("PartNumber").ToString.Contains("'") Then
ErrorLog(row("PartNumber").ToString() & "Not a Valid part number")
ElseIf row("PartNumber").ToString.Contains(",") Then
ErrorLog(row("PartNumber").ToString() & "Not a Valid part number")
Any Ideas?
jds1207
|
|
|
|
|
You could probably make it a little simpler by using the IndexOf method. Something like this:
Dim AnInteger As Integer<br />
AnInteger = YourString.IndexOf(".")<br />
If AnInteger > 0 Then 'something happens here
etc.
Johan
|
|
|
|
|
Hello.
I am currently building a series of ASP.NET pages that serve as reports. All of them offer the possibility of exporting data in Excel format, either by clicking a button or directly setting Response.ContentType to "application/vnd-ms.excel".
To generate the Excel documents I am currently using Office Web Components, version 9. I have generated the necessary wrappers for COM already, added them as reference and is working. However, there is one issue I just can't solve. Some cells in some of the reports need to have the text oriented vertically. I have been looking for some property of the Range object to allow me to do this but so far I didn't found anyhting. It does have HAlignment, VAlignment and such, but nothing that could be used for setting cell orientation.
Does anyone have any suggestions ?
Thanks for attention and hope I didn't posted to the wrong forum.
|
|
|
|
|
How can i execute Command Line Switches of Microsoft Access using Visual Basic 6.0
Please Reply
|
|
|
|
|
All you have to do is add the appropriate switches to the command line that your using to launch Access, usually something like:
C:\Program Files\Microsoft Office\Office\MSACCESS.EXE /repair
You have to specify the full path to the .EXE.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How Can i create any folder ex.c:\hi in setup program(deployment)??
Thank You
|
|
|
|
|
What tool are you using to create the setup program?
|
|
|
|
|
Hi
I had a strange problem. I had incoroporated ActiveX webbrowser control in windows forms (using vs.net 2003). I had recorded some events like click occured on the browser and stored them in the datatable as rows(one row for each event). Now what i want to do is run all these rows one by one. My problem is that the documentcomplete as well as navigatecomplete2 events doesnt fire until the whole method written for the running the events is executed. It creates a problem like i am not able to get the refreshed page in document object after navigation to a new page. Any help will be appriciable.
Thanks & Regards
Gurmeet Singh
|
|
|
|
|
Hi,
I am using COM for Word in my application, when i am going to create the object for Word it gives error "Specified cast is not valid"
My system OS is XP as well as i am using office XP for COM, i already installed Word introp PIA as well as registered all the dlls related to the same.
I am not getting how to resolve the problem?
Can anybody help me regarding this........
honey
|
|
|
|
|
Honey,
what is the type of your receiving variable?
Dim oVar as ?????? '<-- try 'object' unless your are using a reference
Set oVar = CreateObject("...")
Nathan
|
|
|
|
|
Thanks,Nathan
But i already decleared the object as following;
"wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True"
and i got the error on'CreateObject()';which i specified in my previous mail,
Thanks,
Honey
-- modified at 5:25 Thursday 16th November, 2006
|
|
|
|
|
Hi,
I would like to know if visual basic 6.0 (or higher) is able to return a global variable (or kinda) that returns a "true" value or something to indicate that I'm running my application from the development environment (in this case from VB 6.0). I need it to disable some portions of code while I'm debugging some applications.
Thanks a lot
TK
|
|
|
|
|
I'm not sure if vb6 has one built in but you can add your own. In the properties of the project, click the 'make' tab. look at conditional compilation arguments add your own call it IDE (or whatever) and give it a value of True. Then throughout your code you can can test it to whether or not you want to include the code when compiling.
Ex:
Conditional Compilation Arguments: IDE=True
#If Not IDE Then
'include this code
#Else
'??????????????
#End IF
You can use this technique for a lot of things. You can create a huge bas file that would have all the common routines that various projects that could use. But you don't want your exe/dll big because of the amount of code so tell vb what routines you want to include...
Ex: various subs and functions that you may wan to include. give each routine a number and then add all the routines up and give the conditional compilation argument ROUTINES the total.
Sub or Function Value Description
' --------------- ----- -------------
' GB_dtDateValue 1 Function to convert any string date
' to a date value
' GB_dtTimeValue 2 Function to convert any string time
' to a date value
' GB_dtDateTimeValue (8192+1+2) 8195 Function to convert a string containing
' a date and time to a date value.
' GB_iParseString 4 Function to parse a string using a
' specified delimiter
' GB_CenterFormInForm 8 Subroutine to center a called form
' within the caller form
' GB_CenterFormInScreen 16 Subroutine to center a called form
' within the screen
' GB_WindowPos_Save 32 Subroutine to save the position of
' of a form
' GB_WindowPos_Restore 64 Subroutine to restore the position
' of a form
' GB_bNumericKeyPress 128 Function checks to see if a numeric
' key was pressed
' GB_bAlphaKeyPress Function checks to see if a alpha
' key was pressed
' GB_bAlphaNumericKeyPress Function checks to see if a alpha
' or numeric key was pressed
' GB_bIsActiveWindow 256 Function to test whether or not the
' window asked about is active(top)
' GB_GiveFocusTo 512 A routine used to pass focus to a
' window via the handle.
if 1 goes into routines then it will be compiled, the rest of the routines that don't will not be included...
#If (ROUTINES And 1) Then
Public Function GB_dtDateValue(ByVal sDate As String, Optional ByRef bErr, _
Optional bHistoricalDate, Optional bHandleBeep) As Date
End Function
#End If
Hope this helps...
Nathan
-- modified at 10:20 Wednesday 15th November, 2006
|
|
|
|
|
6.0Please any body can give me the code for finding out Manufacturers SERIAL NO. of the HDD or C.P.U or any other hardware connected to Computer Using VB.6.0 or VC++ 6.0. or any link to any website from where I could get it.
Thanking you,
Vilas shirodkar.
|
|
|
|
|
|
Experts please help.
Class parentctrl(Of editctrl)
inherits control
' ... code ...
End Class
Class mylistbox(Of pctrl)
inherits control
' .. code ...
End Class
Now the problem comes when I try to instantiate the class parentctrl providing it with a concrete class in place of the generic. there is an infinite nesting that is created. how do I overcome this.
Dim mycombobox as new parentctrl(Of mylistbox(Of parentctrl(Of mylistbox(Of parentctrl(Of mylistbox(Of parentctrl .... )))))) ()
Is there a keyword like "self" or something that can make the compiler understand that I have provided it enough information to do what i want. If one tries the above code out you will know exactly what the problem is.
|
|
|
|
|
Hi,
I have a DLL called by a client application. The call may occur twice, such that there are two instances running.
What I would like to do is in the New constructor of the DLL, have a routine to check if an instance of the library is already loaded into memory. If so, then the routine would return a pointer to the existing instance, rather than instancing it a separate time.
I imagine this a Reflection issue?
Can anyone help?
Thanks
AndyORS
|
|
|
|
|
Ex: All your code should call 'oclientapp' instead of using 'moclientapp'
Public Class Test
Private moClientApp as Object = Nothing
Public Function oClientApp As Object
If IsNothing(moClientApp) Then
moClientApp =CreateInstance("Client","Application")
End If
Return moClientApp
End Class
Private Function CreateInstance(ByVal sAssembly As String, ByVal sClass As String) As Object
Dim ao As [Assembly], aoName As New AssemblyName
Dim o As Object
Try
aoName.Name = sAssembly
ao = [Assembly].Load(aoName)
o = ao.CreateInstance(sAssembly & "." & sClass, True)
Catch ex As Exception
'ExceptionManager.PublishException(ex)
Throw ex
End Try
ao = Nothing
Return o
End Function
-- modified at 12:07 Wednesday 15th November, 2006
|
|
|
|
|
Hi,
Thanks for your explanation - however I'm still unsure how to apply your code. May I ask you to elaborate perhaps by using the following as an example:
My code might read:
Imports MyLibrary
Public Class Form1
Public ins1 as new MyLibrary
Public ins2 as new MyLibrary
End Class
Thanks,
Andy
|
|
|
|
|
Sorry must of been confused...
The class itself can not do that unless you also give the first pointer to a global/shared variable because the class does not know how many instances of itself have been created. So my code would come into play checking the global/shared variable to whether or not it's nothing.
Your idea of the constructor would not work either. The New event fires when the instance is created. You cannot return a different pointer from the one your are creating. You need to check the variable holding on to the first pointer to see if it's populated or not.
Your example:
Public ins1 as nw Mylibrary 'the pointer of this instance is the only thing that can be return into ins1. the new cannot return a different pointer.
Nathan
|
|
|
|
|
Hi,
I have created a small utility which reads in the contents of a text file, and puts the contents into a datagrid.
The datagrid has 3 columns; 1 = Product, 2 = Quantity, 3 = Value
The product will appear more than once in the datagrid - which is unsorted.
What I want to do is work my way through the grid, and perform a check calculation on all of the Quantities and Values stored against that particular product.
A very simplistic example of the data in the grid might read as follows:
Product3, 5, 2000
Product1, 10, 100
Product3, -5, -2000
Product2, 1, 50
Product2, -1, 50
Product1, -10, -100
The calculation I want to perform is to check the Quantity and Value for each product (Product1, 2 and 3 in this example), and determine whether the nett value is zero (for example, the first Quantity for Product3 is 5, and the second Quantity for Product3 is -5, so the nett is zero). If the value is not zero, I want to add that product to a listbox to summarise where the errors are.
The number of rows in the datagrid may be many thousands - I've even heard rumour that it could be hundreds of thousands (though I've not seen any evidence of this yet )
|
|
|
|