C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

全過去ログを検索

<< 0 >>
■43799  Visual Studio 2008
□投稿者/ kita -(2009/11/19(Thu) 10:50:15)

    分類:[VB.NET/VB2005 以降] 

    Private Sub printFormLine()
    Dim offx As Integer
    Dim offy As Integer
    Dim x As Integer
    Dim y As Integer
    Dim Xtotal As Long = cWCode + bformlineW
    Dim Ytotal As Long = cHLine * cMeisaiLines
    Dim i As Integer

    Dim nPenB As New Pen(Color.Black, 1.0F) ' 太ペン作成
    Dim nPen As New Pen(Color.Black, 0.1F) ' 細ペン作成
    Dim nPenStyle As New Pen(Color.Black, 0.1)

    offx = cXMeisai
    offy = cYMeisai + bhtitleY
    x = offx
    y = offy

    printLine(nPenB, x, y, x + Xtotal, y)

    nPenB.Dispose() ' ペン破棄
    nPen.Dispose()
    End Sub

    下記のように皆で共通して使えるようにライブラリを作ろうと思っているのですがエラーが発生して
      しまいます。何がいけないのでしょうか?  
     
    Module commonDRAW


    Public prContext As Graphics


    Public Function printLine(ByVal pPen As Pen, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer,_
    ByVal y2 As Integer) As Integer

    prContext.DrawLine(pPen, x1, y1, x2, y2)
    End Function
    End Module

    エラー内容
      NullReferenceExceptionはハンドルされませんでした。
      オブジェクト参照がオブジェクト インスタンスに設定されていません。
      とでてきます。

      どなたか解決方法教えて下さい。
親記事 /過去ログ75より / 関連記事表示
削除チェック/

■85954  構造体でのform2にform1からもらう
□投稿者/ PJ -(2017/12/05(Tue) 14:21:48)

    分類:[.NET 全般] 

    初めまして、今悩んでて助言をください

    開発言語Vb.net
    windows Forms

    ’変数の意味、宣言等は割愛

    Form1側
    Private Sub Inspection_form()
    Dim inpe As New Inspection_form.Main
    inpe.finishedproduct = finishedproduct
    inpe.Rec = TextBox1.Text
    inpe.pass_2 = pass
    inpe.Log_List = log
    inpe.My_Config = My_system_F
    inpe.My_Use = My_system_U

    check_form = New Inspection_form
    check_form.Show(Inte_use)

    Form2側
       Public Structure Main_Recive
    Public finishedproduct As String()
    Public Rec As String
    Public Log_List As ListBox
    Public pass_2 As String()
    Public My_Config As String
    Public My_Use As String
    End Structure


    Public Overloads Sub show(Main_Recive As Main_470)

    proda_name.Text = Main_Recive.Rec

    'ボタン
    B = New Button() {Check_bt, stop_bt, Call_bt, end_bt}
    Dim n As String() = File.ReadAllLines(Main_Recive.My_Config & Main_Recive.pass_2(5), enco)
    B(0).Text = n(7)
    B(1).Text = n(8)
    B(2).Text = n(9)
    B(3).Text = n(10)
    'ラベル
    L = New Label() {Cut_timer}
    Dim n2 As String() = File.ReadAllLines(Main_Recive.My_Config & Main_Recive.pass_2(6), enco)
    For i As Integer = 0 To L.Length - 1
    L(i).Text = n2(i)
    Next
    'PDF Load時
    Dim s As Integer = Array.IndexOf(Main_Recive.finishedproduct, proda_name.Text)
    Dim a As String() = Directory.GetFiles(Main_Recive.My_Use & "\" & Main_Recive.finishedproduct(s))
    PDF.LoadFile(a(0))

    show()

    1側の変数には配列なり、コントロールなりを設定
    showしたときに引数を使いForm2呼び出し時の表示はできたのですが


    Form2側でのボタンイベントでの引数が上手くいきません

    Private Sub next_Cl_Click(sender As Object, e As EventArgs) Handles next_Cl.Click
    Dim rec As New Main_470
    next_pro(rec)
    End Sub

    ’クリックイベントでnext_proプロシージャーを呼び出し、構造体の引数付
    Private Sub next_pro(c As Main_470)
    Dim i As Integer = Array.IndexOf(c.finishedproduct, proda_name.Text)
    Dim a As String() = Directory.GetFiles(c.My_Use & c.finishedproduct(i))
    number = number + 1
    PDF.LoadFile(a(number))
    End Sub

    クリックイベントで構造体の型をNewしなければ引数として使えないので
    インスタンスしますが初期化するので
    保持出きていないので、Nothingなります

    構造体の使いたが間違っているのか?
    最近構造体をやり始めてていまいち理解できてないのか
    詳しく教えてください。




親記事 /過去ログ147より / 関連記事表示
削除チェック/

■85956  Re[1]: 構造体でのform2にform1からもらう
□投稿者/ Hongliang -(2017/12/05(Tue) 14:40:34)
    結局その構造体の型名はInspection_form.MainなのかMain_ReciveなのかMain_470なのか。
    他にもInspection_formなのかForm2なのか、とか。
    
    Showの引数で渡されたMain_470(ということにしよう)を、メンバ変数としておいておけばいいんじゃないでしょうか。
    Class Inspection_form
      ' 諸々省略
    
      Private m_Main_Receive As Main_470
    
      Public Sub Overloads Show(ByVal Main_Receive As Main_470)
        Me.m_Main_Receive = Main_Receive
        ' 以下、いろいろ
      End Sub
    
      Private Sub next_Cl_Click(sender As Object, e As EventArgs) Handles next_Cl.Click
        next_pro(Me.m_Main_Recieve)
      End Sub
    End Class
    
    ところで、VBにおける構造体(Structure)は、C言語等における構造体とはちょっと違って、
    限定的な分野でのみ使用するのが基本です。
    ほとんどのケースでは(今回のケースでも)、Classを使用します。
記事No.85954 のレス /過去ログ147より / 関連記事表示
削除チェック/

■85955  Re[1]: 構造体でのform2にform1からもらう
□投稿者/ shu -(2017/12/05(Tue) 14:38:52)
    No85954 (PJ さん) に返信
    > Private Sub next_pro(c As Main_470)
    いまひとつやりたいことがわかりませんが
    構造体を渡すならここは
    ByRef c As Main_470
    にされた方がよいかと思います。
記事No.85954 のレス /過去ログ147より / 関連記事表示
削除チェック/

■85957  Re[2]: 構造体でのform2にform1からもらう
□投稿者/ PJ -(2017/12/05(Tue) 15:06:25)
    No85955 (shu さん) に返信
    > ■No85954 (PJ さん) に返信
    >> Private Sub next_pro(c As Main_470)

    ありがとうございます
    変数や型が適当につけているので見直さないといけませんね
    ご指摘ありがとうございます

    やりたい事はわかりましたので
    解決しました

    Class化ほどのデータではないので
    構造体の作り方を学びたかったのが理由でした

    ある程度できていたのですが
    肝心な部分ができていないので

    まだまだ勉強不足です

    ありがとうございました
記事No.85954 のレス / END /過去ログ147より / 関連記事表示
削除チェック/

■85960  Re[3]: 構造体でのform2にform1からもらう
□投稿者/ PANG2 -(2017/12/05(Tue) 16:18:22)
    No85957 (PJ さん) に返信
    > Class化ほどのデータではないので
    > 構造体の作り方を学びたかったのが理由でした

    いいえ。16 バイト以上のデータであれば、クラス化するべきです。

    クラスと構造体の使い分け
    https://dobon.net/vb/dotnet/beginner/whenusestruct.html

記事No.85954 のレス /過去ログ147より / 関連記事表示
削除チェック/

■91062  c# picturebpx 透過
□投稿者/ ryu -(2019/05/23(Thu) 16:10:16)

    分類:[C#] 

    windouws formでアプリを作っておりform1とform2があります。
    form1で画像を2枚表示して、form2でその2枚の画像の片方を透かして表示したいです。

    form1 pictureBox1 pictureBox2 button1 button2 button3
    form2 pictureBox1 pictureBox2

    public partial class Form1 : Form
    {

    public Form3()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
    pictureBox1.ImageLocation = openFileDialog1.FileName;
    }
    }

    private void button2_Click(object sender, EventArgs e)
    {
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
    pictureBox2.ImageLocation = openFileDialog1.FileName;
    }
    }

    private void button3_Click(object sender, EventArgs e)
    {
    Form5 fm4 = new Form5();
    fm4.Show();
    fm4.pictureBox1.Image = this.pictureBox1.Image;
    fm4.pictureBox2.Image = this.pictureBox2.Image;

    }

    }

    上記まではできているのですがform2ができません
    インターネットで調べてはみましたがいまいちわからず
    どなたかご教授よろしくお願いします。
親記事 /過去ログ157より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -