Luc001 77 Posting Whiz

Found a solution.
Here is my code:

   If e.ColumnIndex = 5 AndAlso Len(e.Value) > 0 Then

            e.CellStyle.BackColor = Color.FromArgb(235, 255, 238)
            e.CellStyle.ForeColor = Color.FromArgb(0, 100, 50)
            e.CellStyle.Font = New Font("Adobe Caslon Pro", 12, FontStyle.Italic)

        ElseIf e.ColumnIndex = 5 AndAlso Len(e.Value) <= 0 Then

            e.CellStyle.BackColor = Color.FromArgb(175, 255, 255)

        End If

Thanks for helping.

Luc001 77 Posting Whiz

Hi,

You can find some information, Here, with example codes

Luc001 77 Posting Whiz

Hi,

You can find an example about Removehandler, Here

Luc001 77 Posting Whiz

Hi,

Add this:

'add control to form
Controls.Add(NT)
Luc001 77 Posting Whiz

Hi,

Here are other ways of doing it with Keychar or CharacterCasing:

  Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    TextBox2.CharacterCasing = CharacterCasing.Upper 'already by formload can you set te Char in a Textbox toUpper
End Sub

Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Char.IsLower(e.KeyChar) Then

            e.Handled = True

            SendKeys.Send(Char.ToUpper(e.KeyChar))

        End If
    End Sub

Hope it helps,

Begginnerdev commented: Correct! +8
Luc001 77 Posting Whiz

Hi,
Try this:

txbStateTaxPcnt.Text = stateSlsTax.ToString("#,0.00")
Luc001 77 Posting Whiz

Hi,

You can add your report files in your application folder and use relative paths (Application startup path or Executable Path) instead of hard-coded paths. For example:

Report.load(Application.StartupPath + "\CrystalReport.rpt")
Luc001 77 Posting Whiz

Hi,

Glad to hear that you found it.

Grtz,

Luc001 77 Posting Whiz

Hi,

In the Form2 Class add the form2_location event and then you can try this:

 Private Sub Form2_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
        Me.Location = New Point(Form1.Location.X + 30, Form1.Location.Y + 30)
    End Sub
themaj commented: Perfect answer +3
Luc001 77 Posting Whiz

Hi,

You can find some explanation about how to use a Do...Loop, Here

Luc001 77 Posting Whiz

Hi,

I think this is a better way to create a textfile:

Dim fs As New FileStream("Towns.txt", FileMode.Create, FileAccess.Write)
        'declaring a FileStream and creating a text file named Towns with 
        'access mode of writing
        Dim s As New StreamWriter(fs)
        'creating a new StreamWriter and passing the filestream object fs as argument

        s.Close()
        'closing the file
M.Waqas Aslam commented: Nice and Perfect +5
Luc001 77 Posting Whiz

Hi,

To create a numeric textbox, look here.

To select a certain length, go to the properties of that textbox and set the Maxlength.

debasisdas commented: agree +13
Luc001 77 Posting Whiz

Hi,

What you also can do is useDES Algorithm.
For more explanation, look here.

See also this thread.

Luc001 77 Posting Whiz

Hi,

No problem :)
Mark this thread as resolved and rating is a way of saying thank you. Don't forget to rate always, thanks. :)

Luc001 77 Posting Whiz

Hi,

You can try something like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If DateTimePicker1.Value > DateTimePicker2.Value Then
            MsgBox("Wrong Date")
        Else
            MsgBox("Good Date")
        End If
    End Sub
debasisdas commented: agree +13
Luc001 77 Posting Whiz

Hi,

You can try this:

For Each dr As DataRow In myDataSet.myTable.Rows
	Me.toolStripTextBox1.AutoCompleteCustomSource.Add(dr("myColumn").ToString())
Next

Make sure you have your AutoCompleteSource set to CustomSource.

bLuEmEzzy commented: Thank u :) +3
Luc001 77 Posting Whiz

Hi,

You should do something like this:

Private treeViewWithToolTips As TreeView

Private Sub InitializeTreeViewWithToolTips() 
    treeViewWithToolTips = New TreeView()
    Dim node1 As New TreeNode("Node1")
    node1.ToolTipText = "Help for Node1"
    Dim node2 As New TreeNode("Node2")
    node2.ToolTipText = "A Tip for Node2"
    treeViewWithToolTips.Nodes.AddRange(New TreeNode() {node1, node2})
    treeViewWithToolTips.ShowNodeToolTips = True
    Me.Controls.Add(treeViewWithToolTips)

End Sub
Luc001 77 Posting Whiz

Hi msqueen082,

It was no problem to help you with the other part of your code.

To avoid that other members will help you with your other problem: Julian dates.
You should first solved this thread and open another one with your Julian's dates problem.

Thanks in advance.

Luc001 77 Posting Whiz

Hi,

Add a label in designtime and place it above the datetimepicker, just like Codeorder showed.

In the properties of the label set the text: - Please Select Date - and the textalign = center.

That's all.

codeorder commented: thanks +1
Luc001 77 Posting Whiz

Hi,

In the properties of the textboxes you doesn't want the focus set Tabstop = False
For the textbox set Tabindex = 0

hercx commented: thanks +2
Luc001 77 Posting Whiz

Hi,

Mark this thread as solved when it answered your problem.

Luc001 77 Posting Whiz

Hi,

Yu can find some VB 2008/2010 tutorials, here.

There some good books depending on the VB version on the net.

Luc001 77 Posting Whiz

Dear Sir/Madam,

I have two form in my application form1 and form2. Here, i want to show the form2 from form1 by using a button. And i want to reverse back to my form1 from form2 using same technique. But i want to close form1 (Not visible=false or hide) after loading form2 and same thing in reverse back also.

I have tried like this....

'for from1
form2.show()
'form1.close ' not accepted
me.close

In my above code whole application is closing.

'for form2
form1.show()
me.close()

Here it is working in form2

I want to know that can we close our current form after showing another form? Please guide me.

Hi,

You just need to go to the properties of your application and set:

Shutdownmode = When last form closes

Your application will only close when last form closes.

Luc001 77 Posting Whiz

Hi,

You should try something like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If CheckBox1.Checked = False Or TextBox1.Text = "" Then
            MsgBox("Error, You forgot something")
        Else
            MsgBox("Progressbar coding goes here")
        End If
    End Sub
debasisdas commented: to the point answer. +8
Luc001 77 Posting Whiz

thanks animal mother. it paints tabpage header. but it doesnt paint remaining part of the tab control... is ther any solution to this..

Hi Ashu26,

You can do it like this;

Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
        'Firstly we'll define some parameters.
        Dim CurrentTab As TabPage = TabControl1.TabPages(e.Index)
        Dim ItemRect As Rectangle = TabControl1.GetTabRect(e.Index)
        Dim FillBrush As New SolidBrush(Color.RoyalBlue)
        Dim TextBrush As New SolidBrush(Color.White)
        Dim sf As New StringFormat
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center

        'If we are currently painting the Selected TabItem we'll 
        'change the brush colors and inflate the rectangle.
        If CBool(e.State And DrawItemState.Selected) Then
            FillBrush.Color = Color.White
            TextBrush.Color = Color.RoyalBlue
            TabPage1.BackColor = Color.LightBlue  ' change the backcloor of your tabpage1
            TabPage2.BackColor = Color.LightGreen ' Change backcolor of tabpage2
            ItemRect.Inflate(2, 2)
        End If

        'Set up rotation for left and right aligned tabs
        If TabControl1.Alignment = TabAlignment.Left Or TabControl1.Alignment = TabAlignment.Right Then
            Dim RotateAngle As Single = 90
            If TabControl1.Alignment = TabAlignment.Left Then RotateAngle = 270
            Dim cp As New PointF(ItemRect.Left + (ItemRect.Width \ 2), ItemRect.Top + (ItemRect.Height \ 2))
            e.Graphics.TranslateTransform(cp.X, cp.Y)
            e.Graphics.RotateTransform(RotateAngle)
            ItemRect = New Rectangle(-(ItemRect.Height \ 2), -(ItemRect.Width \ 2), ItemRect.Height, ItemRect.Width)
        End If

        'Next we'll paint the TabItem with our Fill Brush
        e.Graphics.FillRectangle(FillBrush, ItemRect)

        'Now draw the text.
        e.Graphics.DrawString(CurrentTab.Text, e.Font, TextBrush, RectangleF.op_Implicit(ItemRect), sf)

        'Reset any Graphics rotation
        e.Graphics.ResetTransform()

        'Finally, we should Dispose of our brushes.
        FillBrush.Dispose()
        TextBrush.Dispose()

    End Sub
Luc001 77 Posting Whiz

it works for the final result, but when you click the dropdown button it shows you day and month, I want to pick years only, how can I do that

thanks

Hi,

If you want only a dropdown with years to select without any days and months, then you doesn't need a datetimepicker but only a combobox completed with years.

debasisdas commented: exactly +8
Luc001 77 Posting Whiz

Hi,

You can try this:

'following code resizes picture to fit

        Dim bm As New Bitmap(PictureBox1.Image)
        Dim x As Int32 'variable for new width size
        Dim y As Int32 'variable for new height size

        Dim width As Integer = Val(x) 'image width. 

        Dim height As Integer = Val(y) 'image height

        Dim thumb As New Bitmap(width, height)

        Dim g As Graphics = Graphics.FromImage(thumb)

        g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic

        g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, _
bm.Height), GraphicsUnit.Pixel)

        g.Dispose()


      'image path. better to make this dynamic. I am hardcoding a path just for example sake
        thumb.Save("C:\newimage.bmp", _
System.Drawing.Imaging.ImageFormat.Bmp) 'can use any image format 

        bm.Dispose()

        thumb.Dispose()

        Me.Close()  'exit app
y2kshane commented: thnx for the reply :) work fine +1
Luc001 77 Posting Whiz

Hi,

I found this in the MSDN library for the Hijricalendar and here for the Hebrewcalendar.
Perhaps you can find some information how to solve your problems.

Luc001 77 Posting Whiz

Hi,

You could try:

Dim str1() As String = Nothing
Luc001 77 Posting Whiz

Hi,

That's a datagridview.
For some example Images look, here.

For an explanation, look here.

Luc001 77 Posting Whiz

Hi,

You can do it like this:

Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        TextBox1.Text = ""
    End Sub
Luc001 77 Posting Whiz

Hi,

No it's always first the date and then the time.

After some testing found this:

Dim date1 As Date = #3/7/2008 7:00:00 AM#
        Label1.Text = date1.ToString()
        Dim date2 As Date = #3/7/2008 7:00:00 AM#
        Label2.Text = date1.ToString(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))
tcon commented: a combination of your posts lead me to a solution when i pieced bits of code together. i will post the final solution soon :) +1
Luc001 77 Posting Whiz

Hi,

I think that your sytem time isn't the US time format.
To change the forùmat into US time format use this:

Imports System.Globalization 

        Label1.Text = Date.Now.ToString("hh:mm:ss tt MM/d/yyyy", CultureInfo.CreateSpecificCulture("en-US"))

Hope it helps.

Luc001 77 Posting Whiz

Hi,

No problem, thank me with the arrow key :)

stephen lowry commented: great person thanx again +3
Luc001 77 Posting Whiz

Hi John,

I did some testing and this works like it should, that means that if the file exist it only saves the new added sentences.
This is the tested codes:

Dim strFileName As String
    Dim strFilePath As String = ".\"
 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       
        SaveFileDialog1.Filter = "Text Docs(*.txt)|*.txt|All Files(*.*)|*.*"
        SaveFileDialog1.FilterIndex = 2
        SaveFileDialog1.RestoreDirectory = True


        If strFileName Is Nothing Then
            If SaveFileDialog1.ShowDialog = DialogResult.OK Then
                txtBox.SaveFile(Me.SaveFileDialog1.FileName)
                strFileName = Me.SaveFileDialog1.FileName
            End If
        Else
            txtBox.SaveFile(strFileName)
        End If
    End Sub

' this part of code I used for the Save As event.

 Private Sub btnsaveas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsaveas.Click

        SaveFileDialog1.Filter = "Text Docs(*.txt)|*.txt|All Files(*.*)|*.*"         SaveFileDialog1.FilterIndex = 2
        SaveFileDialog1.RestoreDirectory = True

        If SaveFileDialog1.ShowDialog = DialogResult.OK Then
            txtBox.SaveFile(Me.SaveFileDialog1.FileName)
            strFileName = Me.SaveFileDialog1.FileName
        End If
    End Sub
Luc001 77 Posting Whiz

Hi,

If you want to thank me use the arrow keys :)

Now for the saving problem you can try this:

Dim strFileName As String
              Dim strFilePath As String = ".\"
    
        SaveFileDialog1.Filter = "RTF Files|*.rtf|All files|*.*"
        SaveFileDialog1.FilterIndex = 2
        SaveFileDialog1.RestoreDirectory = True

        ' Save the file
        If strFileName Is Nothing Then
            If SaveFileDialog1.ShowDialog = DialogResult.OK Then
                txtBox.SaveFile(Me.SaveFileDialog1.FileName)
                strFileName = Me.SaveFileDialog1.FileName
            End If
        Else
            txtBox.SaveFile(strFileName)
        End If

I hope it helps.

Luc001 77 Posting Whiz

Hi,
To create a texteditor you should use a richtextbox in stead of a textbox.
But you can try the codes I gave you for a richtextbox !

For the textcolor, change the code into this:

If ColorDialog1.ShowDialog = DialogResult.OK Then            
txtBox.SelectionColor = ColorDialog1.Color        
End If

For the font , change it into this:

If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            txtBox.SelectionFont = FontDialog1.Font
        End If
Luc001 77 Posting Whiz

Hi,

Try something like this:

Dim theConnection As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=book1.xls;Extended Properties=""Excel 8.0;HDR=NO;IMEX=1;""")
theConnection.Open()
Dim theDataAdapter As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", theConnection)
Dim theDS As New DataSet()
Dim dt As New DataTable()
theDataAdapter.Fill(dt)
Me.dataGridView1.DataSource = dt.DefaultView
Luc001 77 Posting Whiz

Hi,

In addition Adatapost has written:

You need to create a parentform, to do so you can use Form1 and rename it parentform.vb. Then you need to set the property IsMDIContainer = true. When you add a new form to your application you'll see that it will create a Form1 again. Then use Adatapost's code.

kvprajapati commented: Helpful! +9
Luc001 77 Posting Whiz

Hi,

I think you can't, because your making a printscreen and that will be printing.

What you need is the create a bitmap that only prints the client area.
here's an example:

Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal _
    hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _
    nYDest As Integer, ByVal nWidth As Integer, ByVal _
    nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _
    As Integer, ByVal nYSrc As Integer, ByVal dwRop As _
    System.Int32) As Boolean
Private Const SRCCOPY As Integer = &HCC0020

' Variables used to print.
Private m_PrintBitmap As Bitmap
Private WithEvents m_PrintDocument As PrintDocument

' Print the picture.
Private Sub btnPrint_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnPrint.Click
    ' Copy the form's image into a bitmap.
    m_PrintBitmap = GetFormImage()

    ' Make a PrintDocument and print.
    m_PrintDocument = New PrintDocument
    m_PrintDocument.Print()
End Sub

Private Function GetFormImage() As Bitmap
    ' Get this form's Graphics object.
    Dim me_gr As Graphics = Me.CreateGraphics

    ' Make a Bitmap to hold the image.
    Dim bm As New Bitmap(Me.ClientSize.Width, _
        Me.ClientSize.Height, me_gr)
    Dim bm_gr As Graphics = me_gr.FromImage(bm)
    Dim bm_hdc As IntPtr = bm_gr.GetHdc

    ' Get the form's hDC. We must do this after 
    ' creating the new Bitmap, which uses me_gr.
    Dim me_hdc As IntPtr = me_gr.GetHdc

    ' BitBlt the form's image onto the Bitmap.
    BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, _
        Me.ClientSize.Height, _
        me_hdc, 0, 0, SRCCOPY)
    me_gr.ReleaseHdc(me_hdc)
    bm_gr.ReleaseHdc(bm_hdc)

    ' Return the result.
    Return bm
End Function

' Print the form …
Luc001 77 Posting Whiz

Hi,

You can try something like this:

Dim myReport as new ReportDocument()
myReport.Load("C:\myReport.rpt")
'Pass database and Parameter info here
myReport.PrinttoPrinter(1,true,0,0) 'This prints one copy of all pages to the default printer, and collates them